If you are using SQL Server Backup v 7 , please click here
To integrate SQL Server Backup to other production batch jobs , you can use command line to start a pre-defined job. Following command line format is for SQL Server Backup v8 or later , Please make sure you are using a latest version of SQL Server Backup product.
The command line format as following:
Run the defined job just like you do it on GUI. SQLServerBackup.exe will not exit until the job finishes.
JOB NAME : The name of the job , case sensitive and must fully match what you see in GUI. If the it contains spaces , please use double quotation marks (" ") before and after the job name.
BACKUP TYPE : It can be one of following values :
- -1 : Use the backup type defined in job for backup job. This value is always set to -1 if the job is NOT a backup job.
- 0 : Force to use full backup for backup job
- 1 : Force to use differential backup for backup job
- 2 : Force to use transaction log backup (remove inactive log entries)
- 3 : Force to use transaction log backup (keep inactive log entries)
- 4 : Force to back up tail of transaction log , and leave database in restoring state.
Return Code :
- 0 if job successes
- -1 if job fails
- -2 if command fails
Suppose a backup job name is "db1_backup" , and execute a full backup on database, the command line as following:
C:\Program Files\SQL Server Backup 8\SQLServerBackup.exe "db1_backup" 0
This walk-through will show you:
- How to get backup sql database in command line
- How to create a simple batch file
In this walkthrough , we suppose you have created a backup job in Backup Manager . We create a simple batch file , this batch file execute a full backup ,then print job result on console screen .
Steps : 1, 2
1) create a batch file as following , and save as C:ackup.bat :
C:\Program Files\SQL Server Backup\SQLServerBackup.exe "db1_backup" 0
if errorlevel 0 goto jobok
if errorlevel -1 goto jobfailed
if errorlevel -2 goto commandfailed
echo job ok.
echo Job failed , please view job report to get detail informaion.
echo **Invalid command line parameter!
2) Run the backup.bat file in command console , the result as following: