Blog › Microsoft
DHCP backups: what Windows does for you, and what it doesn't
If a DHCP server dies, every new device on the network stops getting an address. Knowing exactly how DHCP is backed up saves a lot of panic.
Three different "backups"
| Backup | Automatic? | Good for |
|---|---|---|
| Windows' built-in DHCP backup | Yes, every 60 minutes, to C:\Windows\System32\dhcp\backup | Rolling back a corrupted DHCP database on the same server |
Export-DhcpServer | No, it's a one-off snapshot | Moving DHCP to a new server, or keeping a copy before big changes |
| Full server backup | Yes, on its schedule | Losing the whole server |
The trap is thinking an export is incremental. It isn't. It only contains what DHCP looked like at the moment you ran it. Add a reservation afterwards and it's not in the file.
A nightly export that keeps a week
The export file is tiny, so there's no reason not to take one every night. This script saves a dated copy and deletes anything older than seven days. I save it as C:\Scripts\DhcpBackup.ps1.
# DHCP nightly export - keeps the last 7 days
$folder = "C:\Backup\DHCP"
$file = "$folder\dhcp-$(Get-Date -Format yyyy-MM-dd).xml"
New-Item -ItemType Directory -Path $folder -Force | Out-Null
Export-DhcpServer -File $file -Leases -Force
Get-ChildItem $folder -Filter "dhcp-*.xml" |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-7) } |
Remove-Item -Force
Then schedule it to run at 2am as SYSTEM:
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument '-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\DhcpBackup.ps1"'
$trigger = New-ScheduledTaskTrigger -Daily -At 2am
Register-ScheduledTask -TaskName "DHCP Nightly Export" `
-Action $action -Trigger $trigger -User "SYSTEM" -RunLevel Highest
Test it straight away rather than waiting for 2am:
Start-ScheduledTask -TaskName "DHCP Nightly Export"
Get-ChildItem C:\Backup\DHCP
In Task Scheduler, a Last Run Result of 0x0 means success.
Restoring
Import-DhcpServer -File C:\Backup\DHCP\dhcp-2026-10-18.xml `
-BackupPath C:\Backup\DhcpImportBackup -Leases
Then authorise the server in Active Directory and check the scopes.
One rule: keep the backup folder inside whatever backs up the server. A backup that only exists on the server it protects disappears with it.
← All posts