Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am creating a windows desktop application on visual studio 2012 with front end c#.net and back end MySql database.

My Master database is offline and i want to take backup on live server.

how it is possible?

what are the ways to take backup on live server for windows desktop application having offline mysql database.?

What I have tried:

i have absolutely no idea of how to do it. i had read that it can be done with mysqldump but i guess it is for linux O/S and not for windows.
Posted
Updated 24-May-16 23:50pm
v2

1 solution

you can use following code to take a backup
C#
private void Backup()
{
    string constring = "server=localhost;user=root;pwd=qwerty;database=test;";
    string file = "C:\\backup.sql";
    using (MySqlConnection conn = new MySqlConnection(constring))
    {
        using (MySqlCommand cmd = new MySqlCommand())
        {
            using (MySqlBackup mb = new MySqlBackup(cmd))
            {
                cmd.Connection = conn;
                conn.Open();
                mb.ExportToFile(file);
                conn.Close();
            }
        }
    }
}
 
Share this answer
 
Comments
Member 11460370 13-Jun-16 5:44am    
@koolprasad2003 : this is a nice script but this script only creates the backup on local pc only. i had already done this part, now what i wanted is that to take this backup on any live server for security purpose or create a whole new backup on live server.
i appreciate your answer.
thank you.
koolprasad2003 13-Jun-16 6:25am    
After having backup on local server you can move that backup on live server (upload on server), what is the issue ? where you are stuck ?
djs83 27-Feb-20 4:18am    
hi, can we do this database backup file in automation? Means is it possible to develop an application which will automatically take backup from local server database and will upload changes on cloud server. Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900