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 Files\Microsoft SQL Server\90\Tools\binn\sqlcmd.exe" -U sa -P
DISK='C:\Backups\DatabaseName%ToDaysDate%.bak' WITH FORMAT"

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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: