# SCCM 2012 SP1 Site Backup and Afterbackup.bat2

It’s always better and a preventive thought to Back-up your Daily SCCM 2012 Backup, (keeping a daily copy on the server and copying the backups to an alternate location). Because if your SCCM server falls down you still have a back-up!

In the process of SCCM’s daily backup (visible in smsbkup.log), there’s an ‘AfterBackup.bat‘ file used to perform post-backup actions automatically after the Backup Site Server maintenance task runs successfully. By default, the AfterBackup.bat batch file does not exist. You have to create and place it manually.

As we all know there was a bug in the SCCM 2012 RTM Backup Site procedure. There was a workaround by creating a sub-folder underneath the Backup folder when using UNC paths.

Microsoft stated this would be addressed in SP1 of SCCM 2012, well let’s take a look and check-out the use of the ‘AfterBackup.bat’ procedure!

Activating site backup

ConfigMgr console > Administration tab > Site settings > Site maintainance > Backup site server

Edit and fill out the needed values.

You can set a local or remote UNC backup path and the scheduling options. Whatever you decide you can use the AfterBackup.bat to move or archive it afterwards.

The computer account of the ConfigMgr server has to have been granted full control permissions on the remote backup location.

Creating the AfterBackup.bat file

Here is a simple script for ‘AfterBackup.bat’ written by ‘Garth Jones’, which saves 7 days backup to a folder named after the first 3 letters of the day of the week, and also deletes/overwrites the older ones.

***********************************************************************************

REM @echo off

setlocal enabledelayedexpansion

set target=\\Destination_Server\E$\AfterBackup\%date:~0,3% If not exist %target% goto datacopy RD %target% /s /q :datacopy xcopy “\\Source_Server\*” “%target%\” /E /-Y *********************************************************************************** where, “Source_Server” is the Primary Server from which the backup has to be copied, and “Destination_Server” is the Remote Server where you want to copy the Site Backup. Source_Server (This is the UNC path specified in ConfigMgr) \\SCCM2012\sccm$\_Backup

Destination_Server (This is where we store the backup)

\\FILE01\SCCM\$\SCCM_Backup

Although the intended use of AfterBackup.bat is to archive SCCM backup snapshots, you can use that file for other tasks that you need to perform at the end of every back up operation, such as:

• Run a SQL Server DBCC test to verify that there are no integrity problems with the SCCM Site database.
• Run a site health tool, or other health tools.

Putting the AfterBackup.bat to work

ConfigMgr has the ability to run an after backup batch file which you can use to perform archiving and other administrative functions.

Start by creating the AfterBackup.bat and copy it to the location below.

{ConfigMgrInstallPath}\inboxes\smsbkup.box\AfterBackup.bat

Once it’s in place ConfigMgr will automatically execute its contents at the end of a sms_site_backup task. It runs as the computer system account.

ConfigMgr overwrites each backup when it runs the site backup task. You must use the AfterBackup.bat or manual copy to archive more than one backup.

Starting a backup outside of the schedule

You can start a backup at any time by going into the service manager which can be launched through the console.

Monitoring tab > System Status > Component State > Ribbon > Start > Configuration Manager Service Manager

Once in service manager, locate the SMS_SITE_BACKUP service and right click start. A backup will now start.

Another option is to go to Windows Services.msc and start the SMS_SITE_BACKUP service.

After a successful backup you will see this in your logs:

And the backup is copied over to your alternate backup location!

## 2 thoughts on “SCCM 2012 SP1 Site Backup and Afterbackup.bat”

This site uses Akismet to reduce spam. Learn how your comment data is processed.