Wednesday, 2 September 2015

Setup SQL Express Database Backups

Setup SQL Express Database Backups


SQL Express is great but it has a few limitations. One of these is the lack of SQL Server Agent which is needed to setup maintenance backup plans. This doesn't mean you can't take backups though, just that it needs to be done with a bit of SQL code.

Open up notepad and enter the following:

sqlcmd -S SERVERNAME\INSTANCENAME  -Q "BACKUP DATABASE DATEBASENAME TO DISK='E:\BACKUP\PATH\FILENAME.bak' with INIT"

Save this file as a .bat file. Now you just need to set up a scheduled task to run this file.

Beware, this will overwrite the file every day as it is using the same file name. There are scripts out there which will let you put in a date stamp to get around this but for my purposes I can make do with this as the files are backed up daily to another server anyway.

No comments:

Post a Comment