Backup MariaDB database from Android client (Xamarin)

169 views Asked by At

MySQLBackup.net works fine on Windows applications, but not in Xamarin (tested with exact same code).

Is there any workaround or alternatives that I can use ? I'm really lost...

I want to backup my database from a Linux (Debian9) MariaDB server, so I found MySqlBackup.NET, but nothing can make it work with Xamarin.

There's my code to backup (works in windows console app):

                // Use MySqlBackup.Net to backup database
                using (var conn = new MySqlConnection("myconnstring"))
                {
                    conn.Open();

                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        conn.Open();

                        using (MySqlBackup mb = new MySqlBackup(cmd))
                        {
                            cmd.Connection = conn;
                            mb.ExportToFile(Constants.EXPORT_PATH + "/dolibarr_" + identifier + "dataBackup.sql");
                            conn.Close();
                        }
                    }
                }

Getting exception: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.

1

There are 1 answers

0
adriancs On

I am the author of this library. MySqlBackup.NET uses 3 types of connector. You may use the version which runs with MySqlConnector, this version has the best compatibility for cross platform.

https://www.nuget.org/packages/MySqlBackup.NET.MySqlConnector