Configuring backup in ConfigMgr Current Branch

With the introduction of Configuration Manager Current Branch (CB), the game of backup has changed slightly.  A SQL backup is still valid for restoring the database, but re-installing ConfigMgr CB must be started by running setup.exe from the cd.latest folder. I know most of you are backing up the virtual machine (which is good), but that should not prevent you from not stop you from backing up SQL and Configmgr. You have two options:

  • Create a SQL maintenance plan and include a custom step to backup cd.latest
    • SQL backup Pros
      • Support for compression
      • Better scheduling job
      • E-mail notifications
      • No ConfigMgr service interrupted
      • Include other databases in the backup job
  • Run the ConfigMgr built-in maintenance task
    • ConfigMgr Pros:
      • Easy to configure
      • You do not require any SQL experience
      • Run custom scripts after backup is completed using the old afterbackup.bat method
      • Include cd.latest and other ConfigMgr folders.

Personally I prefer the SQL method as I’m a big fan of compression and do not have time to copy 250 GB. Steve Thompson describes in this blog post how you can configure SQL backup for ConfigMgr 2012. My configuration is a long way exactly the same, except I will include a custom SQL Job. The SQL job will compress and copy .\Program files\Configuration Manager\cd.latest to the same location as my SQL backup files. The PowerShell job require, the SQL agent service to be running and the service account have permissions to the target path.

powershell.exe -command "Add-Type -Assembly ‘System.IO.Compression.FileSystem’ -PassThru | Select -First 1 | % { [IO.Compression.ZIPFile]::CreateFromDirectory(‘d:\program files\microsoft configuration manager\cd.latest’, ‘f:\sqlbck\archive’ + (Get-Date -format ‘yyyyMMddHHmm’) + ‘.zip’) }"

To create the job, follow these steps in SQL Management Studio:

  1. Open SQL Server Agent (ensure the SQL Agent service is running)
  2. Right click Jobs, create a New Job called Copy cd.latest and change the Owner to System (not required, but why not)
  3. Select the Steps page and click New. Configure the step with these values and click OK:
    1. Step name: copy cd.latest
    2. Type: Operating system (CmdExec)
    3. Run as: SQL Server Agent Service Account
    4. Command: Paste in the PowerShell command

      image

  4. Click OK, to close the custom job.

In order to test the job, right click and select Start Job at Step.

Next step in the process is to configure a backup configmgr maintenance plan as described by Steve Thompson. I have followed the same steps, but will also include my custom copy cd.latest step in the plan.

  1. in SQL Management Studio, navigate to Management. Right click Maintenance Plans, and click Maintenance Plan Wizard.
  2. On the SQL Server Maintenance Plan Wizard page, click Next.
  3. Create a new plan with these settings:
    1. Name: SCCM Backup
    2. Run as: Select SQL Server Agent service account
    3. Select Single schedule for the entire plan or no schedule.
    4. Schedule: Click Change to configure a schedule
    5. Configure the schedule to match your backup criteria’s
  4. On the Select Maintenance Tasks page, select the following maintenance tasks:
    Clean Up History
    Back Up Database (Full)
    Maintenance Cleanup Task
    Execute SQL Server Agent Job

    image

  5. On the Select Maintenance Tasks Order page move Execute SQL Server Agent Job to the end and click Next.
  6. On the Define History Cleanup Task page, configure Remove historical data older than 1 week(s) (or what ever value you want) and click Next.
  7. On the Define Back Up Database (Full) Task page, in the General tab click All databases
  8. Still on the Define Back Up Database (Full) Task page, click the Destination tab and configure these settings and click Next:

    Create a backup file for every database: enable Create a sub-directory for each database
    Set backup-compression: Compress backup.

  9. On the Define Maintenance Cleanup Task page, configure these settings and click Next:
    Delete files of the following type: Backup files
    Search folder and delete files based on an extension. In Folder, type you backup destination folder e.g. F:\SQLBCK, select Include first level subfolders and in File extension, type bak.
    File age configure Delete files based on the age of the file at task run time and Delete files older than 1 week(s).
  10. On the Define execute SQL Server Agent Job task page, select Copy cd.latest and click Next.

    image

  11. Finish the wizard

Now is the time of truth, right click your maintenance plan and click Execute. Creating the zip file will take a few minutes, but once it’s done you have a complete backup set.

image

Huge thanks to my colleague Claus Codam for helping out with the PowerShell step.


Comments (9):

  1. Tim says:

    Hello, Great post!

    Can you explain how to configure this if you have a remote SQL server. So the \Program files\Configuration Manager\cd.latest isnt on the same server / drive / disk.

    Thnx!

  2. Pascal says:

    Hi Kent,

    great script and tutorial. How about cleanup of the .zip-file? The regular SQL cleanup job won’t delete .zip-files older than X days, right?

    Pascal

  3. Sveinung says:

    The CD.Latest folder is automatically copied by the SCCM Site Backup task in SCCM 1511.

    Layout in destination backup path when using same UNC for SQL/SCCM:
    \CD.Latest
    \SiteDBServer
    \SiteServer
    \BackupDocument.xml
    \ConfigMgrBackup.ini
    \smsbkup.log

  4. Fred says:

    Does the SCCM Site Backup task work well for you in 1511 if backed up on UNC ?
    I get problems with cd.latest folder

    Error: Failed to backup \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\PROGRAM FILES\MICROSOFT CONFIGURATION MANAGER\CD.LATEST up to \\UNC\BackupSCCM\SMSBackup\CD.Latest: ERROR: CTool::TreeCopy to \\UNC\BackupSCCM\SMSBackup\CD.Latest failed. Error = [error code: 5, error message: Access is denied.]. SMS_SITE_BACKUP 2016-02-05 08:29:38 1584 (0x0630)

    All other folders work and get backed up

    If I do it on local drive it works

    Security does not differ from other drives

    • olivier says:

      Hi
      I had the same problem with the backup of CD.latest
      i add an exeption on viruscan to resolve this issue

      (Bloqué par une règle de protection de l’accès NT AUTHORITY\SYSTEM SYSTEM:REMOTE G:\SCCMBackup\P03Backup\CD.Latest\autorun.inf Protection standard antivirus:Empêcher la création à distance de fichiers d’exécution automatique Action bloquée : Créer)

  5. Dan says:

    The following modification to the job will delete aging zip files in the backup directory. Some paths changed for my test environment.

    powershell.exe -command “Get-ChildItem -Path ‘D:\SCCM_Backup\*’ -Include ‘*.zip’ | Where-Object {$_.CreationTime -lt (Get-Date).AddDays(-7)} | Remove-Item; Add-Type -Assembly ‘System.IO.Compression.FileSystem’ -PassThru | Select -First 1 | ForEach-Object { [IO.Compression.ZIPFile]::CreateFromDirectory(‘c:\program files\microsoft configuration manager\cd.latest’, ‘D:\SCCM_Backup\cdlatest’ + (Get-Date -format ‘yyyyMMddHHmm’) + ‘.zip’) }”

  6. Andrew Lukaszewski says:

    Not sure I completely agree with the SQL only method for SCCM backup as it has always been considered a last chance method of restoration if you do not have a full Configuration Manager backup available. The CM backup has long been the preferred method of SCCM backup and I’m not sure Microsoft would say otherwise . Also, think of all of the existing log files and inboxes files that are coming in from client systems/in process/not yet committed to database and not included in a database only backup.

  7. Andrew – Microsoft supports restore from a native SQL backup since CM 2012 Sp1. Disagree with last ditch, SQL backups are better for a lot of reasons. For more information please see: https://stevethompsonmvp.wordpress.com/2013/06/07/sql-server-backup-recommendations-for-configuration-manager/

  8. […] Configuring backup in ConfigMgr Current Branch […]

Leave a Reply