Home > Net >  i need proper way of backing up MYSQL database from Desktop Application to online server
i need proper way of backing up MYSQL database from Desktop Application to online server

Time:10-14

first of all i want to clarify that i have been using "mysqldump"and "mysqlbackup" for backing up my data locally but my question is a bit different, i have POS application and i have multiple users so all of them has their own database i have kept same database name for all of them for now, so what i exactly want is that i have given them a option to backup their database online and i am manually adding each datarow to the online database and i have to make different database for all clients separately which is a big hussle and for sure not a proper way of backing it up i have my own domain and hosting server on namecheap.com and i have online mysql server in there

so what i want is what is the proper / professional way of backing up data from an desktop app to online servers

that's the current way i am backing up mysql data to online mysql server database

var CON_ONLINE = new MySqlConnection(MY_SETTING_ONLINE_CON_STRING);
string TABLE_SQL_BUILDER = @"Insert into `"   TABLE_NAME.ToLower()   "` values "   TABLE_DATA_FORMAT;
CON_ONLINE.Open();
string LAST_RECORD = Strings.Left(TABLE_SQL_BUILDER, TABLE_SQL_BUILDER.Length - 1)   ";";
// LOGTXT_WRITER(Environment.NewLine & "LAST REC > " & LAST_RECORD)
using (var cmd2 = new MySqlCommand(LAST_RECORD, CON_ONLINE))
{
    cmd2.ExecuteNonQuery();
}

TABLE_SQL_BUILDER = "";
LAST_RECORD = "";
CON_ONLINE.Close();

CodePudding user response:

the simplest way to backup data on remote servers is to upload the dump file to the server preferably to FTP server instead of writing the whole data to the database online

you can use FtpWebRequest to upload the file to the server here is the code just in case you need it

 var url = "ftp://ftp.example.com/remote/path/file.zip";
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential("username", "password");
request.Method = WebRequestMethods.Ftp.UploadFile;  

using (Stream fileStream = File.OpenRead(@"C:\local\path\file.zip"))
using (Stream ftpStream = request.GetRequestStream())
{
    fileStream.CopyTo(ftpStream);
}
  • Related