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.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.