Automatic MSSQL 2008 Backup Batchfile

I was asked to create a simple process for backups to a MSSQL database. After a little searching around online I came up with a Windows batchfile, and then used scheduled tasks to run it weekly:

set ToDaysDate=%date:~3,2%%date:~0,2%%date:~6,4%

"C:Program FilesMicrosoft SQL Server90Toolsbinnsqlcmd.exe" -U sa -P
Password -S .INSTANCENAME -Q "BACKUP DATABASE DatabaseName TO
DISK='C:BackupsDatabaseName%ToDaysDate%.bak' WITH FORMAT"

This saves a backup file in the folder you specify with the data appended – i.e. DatabaseName161110.bak

Tagged with: , ,

Leave a Reply