Friday, March 18, 2016

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 posthow 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 clickNext.
  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.

link from: http://blog.coretech.dk/kea/configuring-backup-in-configmgr-current-branch/

No comments:

Post a Comment