28 January 2009

Windows 2008: Automate Command line backups

Windows 2008 backups has been driving me around the bend for a while now. Our corporate backup client is not supported on Win2008, and gone is NTBackup that we all have grown to loathe love so much over the past, what 400 years. From my experience, the backup utility included with Win2008 is limited in so many ways, but you can work around most of the limitations by using the command line.

The backup command looks like this:

wbadmin start systemstatebackup -backupTarget:<VolumeName> [-quiet]



Where VolumeName is the drive letter of the drive to store the backup on. (More info here). You will need to run this command with elevated permissions.



runas



By default, the backup command will not allow you to do store the backup on a drive that contains system information. To change this, you need to modify the registry on the machine as follows:




[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wbengine\SystemStateBackup]

"AllowSSBToAnyVolume"=dword:00000001




If the key does not exist, you will need to create it.



Now you will be able to write the backups to any drive on the server.



But, this is still a manual process. And we don’t like manual.



So, to automate the process, you will want to first create a batch file containing the backup command, that now looks like this, for example:




wbadmin start systemstatebackup -backuptarget:d: -quiet




Next up, you want to create a scheduled task. Open up Server Manager, and browse to Task Scheduler



compmgr1



Choose the library you want to create your task in. Right click, create new task (not basic task)



backupsschedule3



Give it a name, make sure the running account is correct and tick Run whether user is logged on or not and Run with highest privileges.



Set your schedule under Triggers, and then, under Actions, select your script.



Note: If you run this command daily, make sure you have enough disk space. Each backup takes up around 10GB, depending on your system configuration, and a new backup is created every time the command is run. The command does NOT delete old backups.



For more information about the backup command set, read here.

3 comments:

sympho said...

Does Windows 2008 provide any way to automatically back up databases? At the moment I use it to back up my server's files only, and what I'd like is to find something for MySQL-based websites.
After certain research I bought a program called Handy Backup -- seems to work very well and runs on 2008 Server. But if there's a free and simple way to backup databases in 2008, I'd consider migrating from 2003...

sympho said...

"At the moment I use it" - Windows' scheduler, I mean.

Vanessa said...

@sympho: It would probably be easier to script this from within your MySQL installation than trying to get the OS to do this. A quick google delivered this site which seems to contain a very nice scripts for backing up MySQL. Once you have created the script, you can then run it with Task Scheduler.
Unfortunately, it has been a couple of years since I have used MySQL, since I now only really use MSSQL, so this is the best solution I can offer.

Related Posts with Thumbnails