Date created: 06/19/11 10:00:45. Last modified: 12/13/12 11:41:20

Backup Group Policy

I couldn't find a sensible way to perform regular backups of Group Policy objects which I can easily organise and quickly restore. The built in NTBackup of Win2k3 is to much hassel so I wrote this batch script to do it for me under a scheduled task. I have never tested it on Windows 2k8 / 2k8 R2 as at the time the FSMO role for the domain holder was still a 2k3 server;

@echo off
net use T: \\backupserver\grouppolicybackups\
sleep 10
for /f "tokens=1,2,3,4 delims=/ " %%a in ('DATE /T') do set tdate=%%d-%%b-%%c
set bdir="T:\%tdate%"
mkdir %bdir%
"C:\WINDOWS\SysWOW64\cscript.exe" "C:\Program Files (x86)\GPMC\Scripts\BackupAllGPOs.wsf" %bdir% /comment:"All GPOs %tdate%" /domain:domain.local
net use T: /DELETE /Y

All that is required to run this script is that GMPC is installed as the installation creates the "Scripts" folder under the GMPC folder in Program Files which contains many useful scripts including the one I used, "BackupAllGPOs.wsf" to dump all GPOs for the passed domain name. One thing to note is that this script was written for Win2k3 R2 so it calls the cscript.exe launcher in the SYSWOW64 folder otherwise calling the 32bit script on a 64bit machine causes errors creating objects and the script fails. This would need changing to run on a 32bit machine.