private void btnBackup_Click(object sender, EventArgs e) { if (UtilitiesMngr.isFieldsEmpty(new object[] { txtBackupLocal, txtFolderLocation, txtMysqlPassword, txtMysqlUsername })) { string db = "A"; if (cbDatabases.SelectedIndex != 0) { db = "B" + cbDatabases.Text; } List <string> cmdlst = new List <string>(); cmdlst.Add("cd " + '"' + txtFolderLocation.Text + @"\bin" + '"'); cmdlst.Add(string.Format("mysqldump --add-drop-table -u{0} -p{1} -x -e -{2} > " + '"' + "{3}\\backup{4}.sql" + '"', txtMysqlUsername.Text, txtMysqlPassword.Text, db, txtBackupLocal.Text, Data() + db.Substring(1) )); tssl1.Text = "Backing up..."; DirMngr.runCmdExit(cmdlst); tssl1.Text = "Backup Complete"; } else { tssl1.Text = "Empty Fields"; } }
private void btnRestore_Click(object sender, EventArgs e) { using (OpenFileDialog opd = new OpenFileDialog() { Filter = "SQL Script|*.sql", Multiselect = false }) { string path, db = ""; if (opd.ShowDialog() == DialogResult.OK) { path = opd.FileName; if (cbDatabases.SelectedIndex != 0) { db = "--database=" + cbDatabases.SelectedText; } List <string> cmdLst = new List <string>(); cmdLst.Add("echo off"); cmdLst.Add("cd " + '"' + txtFolderLocation.Text + @"\bin" + '"'); cmdLst.Add(string.Format("mysql -u{0} -p{1} {2} < " + '"' + "{3}" + '"', txtMysqlUsername.Text, txtMysqlPassword.Text, db, path )); tssl1.Text = "Restoring..."; DirMngr.runCmdExit(cmdLst); tssl1.Text = "Restore Complete"; } } }