How to Back Up Your Group Policy Settings on Windows
Group Policy settings allow you to manage and configure the admin-level settings of your computer. We're not discussing basic settings like tweaking the display brightness or changing the Windows theme. It's a matter of more than 2,000 settings!
However, what if you want to have a backup of your modified settings or restore your configuration to another PC? So, let's see how to back up all the Group Policy settings on Windows.
Why Should You Back Up Your Group Policy Settings?
Creating a backup allows you to experiment with and modify your settings without worrying about misconfiguration. Even if you mess up somehow, restore your settings from the backup, and you'll be up and running quickly.
Also, if you frequently change your settings or reinstall Windows, backing up your Group Policy settings can save you a lot of time. Instead of manually modifying your settings each time or resetting the group policies, you can simply restore them.
But the main headache is how you can do it.
We have categorized this guide into manual backup and an automation setup. Don't worry; we've tried to keep the steps simple with attached screenshots for proper guidance.
How to Back Up the Group Policy Settings Manually
There are two methods for manually backing up Group Policy settings. Let's look at the first one: manually copying the group policy configuration files.
Method 1. Copy the GroupPolicy Directory
There's a separate folder or directory on Windows that stores all your modified Group Policy settings. This folder is located at C:\Windows\System32\GroupPolicy.
Here's how you can back up the Group Policy settings via the GroupPolicy directory:
- Open File Explorer (Win + E) and navigate inside the C:\Windows\System32\GroupPolicy directory.
- Once you're in the GroupPolicy directory, select all the files and folders by pressing Ctrl + A.
- Right-click on any selected files, and click the Copy button (or press Ctrl + C).
- Open the location where you wish to store your backup. This could be a folder on your desktop, a separate hard drive, or a cloud storage service like Google Drive. We're storing the backup files on a separate disk volume for simplicity.
- Now create a new folder in your backup location (a new volume, in our case) and give it a name. In our case, the folder's name is "Group Policy Backup Folder."
- Paste all the files and folders (inside the new folder) you previously copied by pressing Ctrl + V.
That's it! Now whenever you tweak a Group Policy setting, you can copy the modified files using the same steps.
For example, suppose we tweak the printer settings in the Local Group Policy Editor. After tweaking, we need to copy the files from the mentioned directory to our backup folder on the desktop.
To restore the settings, move all the files from our backup folder to the C:\Windows\System32\GroupPolicy directory.
Now that you've got an idea of backup, why not learn some useful Windows Group Policy tweaks to play with?
Method 2. Use a Batch Script
In addition to manually copy-pasting the modified files, you can create a batch script to simplify the process. With a batch script, you don't need to do the copying and pasting work yourself; you just have to double-click the .BAT script to make the magic happen.
First, open a text editor program of your choice. There are many different text editors for Windows, but we'll demonstrate the steps using the default app called Windows Notepad.
Next, copy and paste the code provided below into your text editor:
@echo off
set BACKUP_DIR=%USERPROFILE%\Desktop\Group Policy Backup Folder
if not exist "%BACKUP_DIR%" (
md "%BACKUP_DIR%"
)
xcopy /E /I /Y "C:\Windows\System32\GroupPolicy" "%BACKUP_DIR%"
attrib -H -S "%BACKUP_DIR%"
attrib -H -S "%BACKUP_DIR%\*.*" /S /D
Now, save the file by pressing Ctrl + S. Give it the name "Backup-Script.bat" without the double quotes. We recommend saving this script on your desktop for ease of access. Then, change the Save as type to All files (*.*).
After saving it, go to your desktop and run the script as an administrator. The script will create a new folder on your desktop named "Group Policy Backup Folder."
Please note that you'll need to manually run the script as an administrator whenever you modify a Local Group Policy Editor setting. The script will automatically copy the configuration files to the backup folder when run.
While we only showed the batch script for backing up, there are many other ways to use batch scripts on Windows.
How to Automatically Back Up Your Group Policy Settings
While manual backups are a good start, there may be times when you forget or skip the process. To streamline and automate the backup, you can use our PowerShell script.
With that, any changes made in the Local Group Policy Editor will automatically save to a separate folder as a backup. Thus, eliminating the need for manual work.
Step 1: Create a Windows PowerShell Script
Open a text editor again and paste the following code:
$source = 'C:\Windows\System32\GroupPolicy'
$backupFolder = "$env:USERPROFILE\Desktop\Group Policy Backup Folder"
if (-not (Test-Path $backupFolder)) {
New-Item -ItemType Directory -Path $backupFolder | Out-Null
}
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $source
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
$action = {
if ($Event.SourceEventArgs.Name -eq "GPT.ini") {
Copy-Item -Path $source\* -Destination $backupFolder -Recurse -Force
}
}
Register-ObjectEvent $watcher "Changed" -Action $action | Out-Null
while ($true) {
Start-Sleep -Seconds 1
}
Save this PowerShell file on your desktop as Backup-Script.ps1 (the extension is .PS1, not .BAT this time). Once done, don't run the script now; proceed to the next step.
Step 2: Schedule a Backup Task
Now, we'll use the Windows Task Scheduler to automate the backup process. We'll create a task that launches our PowerShell script on every Windows boot.
The script will monitor the Local Group Policy Editor for any changes. If the script detects a modified setting, it will automatically save the backup files to our designated folder.
Follow these steps to schedule an automation task:
- Launch the Task Scheduler.
- Click on Action > Create Basic Task and give your task a suitable name.
- Click the Next button to proceed. Under Task Trigger, select When the computer starts and click Next.
- You don't need to select any additional options on the current screen; simply click Next again to proceed.
- In the textbox labeled Program/script, paste the following path without the double quotes: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe".
- In the Add arguments field, type or copy-paste the following: -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Users\%USERNAME%\Desktop\BackupScript.ps1"
- Click Next to continue.
- Review your task details and click on Finish to create the automation task.
You have successfully set up an automated backup system on your computer. Whenever you modify the Group Policy settings, the script will automatically save them to the Group Policy Backup Folder located on your desktop.
Enjoy Hassle-Free Group Policy Editing
With over 2,000 settings to tweak in the Group Policy Editor, imagine reconfiguring your favorite settings after a factory reset or during a new PC setup. Thankfully, using our automation script or manual copy-pasting, you can quickly restore your customized settings and ensure they are not lost. Additionally, a backup can also help in case of corruption in local group policy.