Endpoint Insights

How Do You Automatically Backup ConfigMgr Reports Using AfterBackup.bat?

In a recent blog post entitled, “How Do You Backup All of Your Custom ConfigMgr Reports?” I showed you how to backup these reports using PowerShell. I love that process, but it is a one-time backup so, how do you backup all of your ConfigMgr reports every time your ConfigMgr site gets backed up? If you are using the built-in ConfigMgr backup task, the answer is simple: edit your AfterBackup.bat.

In a post from 2015, I used a PowerShell script to make a copy of the ConfigMgr backup for 7 days. This time I will edit the AfterBackup.bat and add a second PowerShell script to backup the ConfigMgr reports.

Here are the steps that you will need to perform:

1. First, in order to create and test the PowerShell (PS) script, review the blog post, “How Do You Backup All of Your Custom ConfigMgr Reports? It is important that this step be completed BEFORE proceeding to the next step.

2. Copy the PowerShell script to your ConfigMgr site server under <Install Directory>\inboxes\smsbkup.box\ ConfigReportsBak.ps1.

3. Edit the PowerShell script and change Line 21 to your ConfigMgr backup directory; add the folder called Reports. In my example below, D:\CMbak\RS2Backup\Reports, I highlighted the line. You will notice that the Data&Time variable is no longer used.

How Do You Automatically Backup ConfigMgr Reports Using AfterBackupbat-Line 21

4. Edit the AfterBackup.bat and add the following line to it. Note: Watch out for word wrapping as well as the stylized quote for both the single and double quotes.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -ExecutionPolicy Bypass -file “D:\Program Files\Microsoft Configuration Manager\inboxes\smsbkup.box\ConfigReportsBak.ps1”

5. Test the backup; make sure that the reports are backed up.

Once this is done, your ConfigMgr reports will be backed up every time the ConfigMgr backup occurs.

Conclusion: How Do You Automatically Backup ConfigMgr Reports Using AfterBackup.bat?

I can hear some of you protesting because many MVPs do NOT recommend using the ConfigMgr backup process in ConfigMgr Current Branch. Let me be the first to say that I’m not one of those MVPs that advises only to use the SQL backups. Having said that, how can you do this as part of the SQL backup process? In a blog post next week, I will show you how to do the same thing using the SQL agent.

If you have any questions, please feel free to contact me at @GarthMJ or reach out to Recast Software here.

Support

  • This field is for validation purposes and should be left unchanged.