Резервное копирование/восстановление базы данных Postgres из C# - CodeProject
Postgres Database Backup/Restore From C# - CodeProject
Что я уже пробовал:
private void butBackup_Click(object sender, EventArgs e) { try { if (textBox1.Text == "-------") { MessageBox.Show("Select the location to save"); return; } StreamWriter sw = new StreamWriter("DBBackup.bat"); // Do not change lines / spaces b/w words. StringBuilder strSB = new StringBuilder(strPG_dumpPath); if (strSB.Length != 0) { strSB.Append("pg_dump.exe --host " + strServer + " --port " + strPort + " --username postgres --format custom --blobs --verbose --file "); strSB.Append("\"" + textBox1.Text + "\""); strSB.Append(" \"" + strDatabaseName + "\r\n\r\n"); sw.WriteLine(strSB); sw.Dispose(); sw.Close(); Process processDB = Process.Start("DBBackup.bat"); do {//dont perform anything } while (!processDB.HasExited); { MessageBox.Show(strDatabaseName + " Successfully Backed up at " + textBox1.Text); } } else { MessageBox.Show("Please Provide the Location to take Backup!"); } } catch (Exception ex) { } }