Backup SQL Server Database from command line

backup SQL Server Database from command lineOne of the most important operations and tasks that need to be performed on a database is the backup process.
In this sense, you can prompt to backup a SQL Server database from the command line using SQLBackupAndFTP with some additional parameters, which are also passed in the command terminal.

SQLBackupAndFTP offers multiple options for backing up your databases, using commands from the command prompt terminal.

 Backup SQL Server Database from command line

These command line options will allow you to achieve different tasks, like backup SQL Server Database from the command line or open and edit a backup job, schedule a job to run etc.

 Below is a list of some of the commands you can run to achieve different tasks:

    • In order to run a job (either immediately or based on a schedule) you should run the following command:
SqlBackupAndFTP.exe -rn <filename.jobx> [{-diff|-log|-fullcopy|-logcopy}]

Examples of commands to Backup SQL Server database from the command line:

"C:Program FilesSQLBackupAndFTPSQLBackupAndFTP.exe" -rn "C:new.jobx"
"C:Program FilesSQLBackupAndFTPSQLBackupAndFTP.exe" -rn "C:new.jobx" -diff
"C:Program FilesSQLBackupAndFTPSQLBackupAndFTP.exe" -rn "C:new.jobx" -log
"C:Program FilesSQLBackupAndFTPSQLBackupAndFTP.exe" -rn "C:new.jobx" -logcopy
"C:Program FilesSQLBackupAndFTPSQLBackupAndFTP.exe" -rn "C:new.jobx" -fullcopy 

If you like to perform other types of operation on jobs, below you can find the commands for two of the most common actions:

      • Opening a job for editing with SQLBackupAndFTP:
SqlBackupAndFTP.exe <filename.jobx>
      • In order to schedule a job to run with SQLBackupAndFTP:
SqlBackupAndFtp.exe -s <filename.jobx> [<username> <password>]

These are the commands for the most common operations which allow you to backup SQL Server Database from command line prompt while using SQLBackupAndFTP.

Important Note:

Whenever you are scheduling a job with SQLBackupAndFTP from the command line, it automatically uses the “-rn” option. This option is recommended in order to achieve better performance for your backup job compare to using the “-r” option.

If you need to see the output of the job in the console, then you should use the explicit “-r” option instead.

[Total: 3    Average: 4/5]

About Radu Gheorghiu

Passionate SQL Developer on the journey of trying to become an expert in all things Data (storage, manipulation, gathering etc.)

Information is power, and information can only be obtained from data. Thus, in order to harness the power of information, you must be a master of Data.

Leave a Reply

Your email address will not be published.