One 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 version 10 or earlier with some additional parameters, which are also passed in the command terminal.
SQLBackupAndFTP version 10 or earlier offers multiple options for backing up your databases, using commands from the command prompt terminal.
This option is also available in SQLBackupAndFTP version 11 but there are some differences. Follow this link to find more details on how to run SQLBackupAndFTP version 11 from a command line.
Backup SQL Server Database from the 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:
-
Creating a Full backup
"C:\Program Files\SQLBackupAndFTP\SQLBackupAndFTP.exe" -rn "C:\new.jobx"
-
Creating a Differential backup:
"C:\Program Files\SQLBackupAndFTP\SQLBackupAndFTP.exe" -rn "C:\new.jobx" -diff
-
Creating a Transaction log backup:
"C:\Program Files\SQLBackupAndFTP\SQLBackupAndFTP.exe" -rn "C:\new.jobx" -log
-
Creating Copy-only log backups:
"C:\Program Files\SQLBackupAndFTP\SQLBackupAndFTP.exe" -rn "C:\new.jobx" -logcopy
-
Creating Copy-only full backups:
"C:\Program Files\SQLBackupAndFTP\SQLBackupAndFTP.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 version 10 or earlier.
Important Note:
Whenever you are scheduling a job with SQLBackupAndFTP version 10 or earlier from the command line, it automatically uses the “-rn” option. This option is recommended in order to achieve better performance for your backup job compared 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.