0

Sql Server has the capability to backup a database to a file using ado.net

var path = @"C:\MyPath";
var databaseName = "Foo";

var backupFilename = string.Format ( "{0}.BAK", databaseName );
var backupPath = Path.Combine ( path, backupFilename );

if ( File.Exists ( backupPath ) )
  File.Delete ( backupPath );
                    
using ( var cmd = DbConnection.CreateCommand () )
{
   var selectQuery = 
      string.Format ( "BACKUP DATABASE {0} TO DISK = '{1}'", 
                       databaseName, backupPath );

   cmd.CommandType = CommandType.Text;
   cmd.CommandText = selectQuery;

   cmd.ExecuteNonQuery ();
}                    


I have seen pg_dump, and understand it is an exe installed by Postgre to backup a database. I would not have access to the server to run pg_dump. Can Postgre pg_dump be run from ado.net or is there a script alternative to it that could be used.

dgxhubbard
  • 703
  • 2
  • 7
  • 18
  • Below are the sources that I have found but it all points to running pg_dump for a backup: – dgxhubbard May 18 '22 at 16:17
  • More information: https://stackoverflow.com/questions/33854798/how-do-i-install-just-the-client-tools-for-postgresql-on-windows https://stackoverflow.com/questions/57395533/running-pg-dump-from-another-machine https://sagartajpara.blogspot.com/2017/03/postgres-database-backup-in-c.html https://stackoverflow.com/questions/23026949/how-to-backup-restore-postgresql-using-code – dgxhubbard May 18 '22 at 16:17

0 Answers0