Tuesday, May 06, 2008 9:08 AM
cmosby
Excerpts from Mastering System Center Configuration Manager 2007 book: Chapter 7 - Disaster Recovery
I appreciate everyone’s patience as we try to get this book done and on the shelves. With that in mind, here is an excerpt from one of the chapters, with information that can be also be used with SMS 2003. I hope you find it useful.
Using the AfterBackup.bat File
Starting with previous versions of Configuration Manger, Microsoft includes support for a batch file appropriately called AfterBackup.bat to run tasks on the site server after the backup task is complete. After successfully running the Backup ConfigMgr Site Server maintenance task, it will try to run this batch file. This batch file is not installed during site setup and will have to be created manually by an administrator after a site server is configured.
If the AfterBackup.bat file exists, and is stored in the correct folder on the site server, the batch file will run automatically after the backup task is complete. The AfterBackup.bat allows you to include commands that will archive the backup snapshot to a location off the server at the end of the backup operation, and perform other post-backup tasks if you include them in the batch file.
The AfterBackup.bat file integrates the archive and backup operations, thus ensuring that every new backup is archived. If the batch file does not exist it has no effect on the backup success, but in order to archive the backup snapshot, you must use another method.
Although the AfterBackup.bat file is intended to archive backup snapshots, you can include commands in that batch file that will run after every backup like, SQL Server DBCC tests to verify database integrity, or any other health checks on the site server.
Archiving the Backup Snapshot to another server with AfterBackup.bat
The AfterBackup.bat file is supposed to do two primary functions.
· Archive a copy of the latest backup to a remote location off of the Site Server that is being backed up.
· Copy that backup in such a way that there is multiple archived copies of site server backups, in case one is corrupted or one of the backup cycles fails.
However, this file isn’t created for you when ConfigMgr is installed and the ConfigMgr documentation does not explain how to setup the AfterBackup.bat file to be able to accomplish this task.
There are several ways to do this (including using third-party tools), some more complicated than others, but probably the simplest way to do this is to use the Windows Command XCopy.
xcopy "[location of backup files on site server]\*.*" "\\[off site location]\%DATE%\[sitecode]Backup\*.*" /E /O /C
Add this command to an ASCII file and name it AfterBackup.bat, then place the batch file in the following location:
[Drive where ConfigMgr is installed]\ SMS\inboxes\smsbkup.box
Now this isn’t the perfect solution, but it will get the job done. One of the drawbacks of archiving this way is that the files will copied over the network uncompressed to your remote file location. Depending on the size of your ConfigMgr database, archiving may take a long time and might use up a lot of bandwidth if your remote location is on a slow link.
With that in mind, you can also add commands to the AfterBackup.bat file to use file compression software like WinZip or PKZip; to compress the backup file before they are copied to the remote archive location.
Filed under: SMS, On a personal note...., ConfigMgr