
DNS is the first thing that breaks everything else: Active Directory logons, websites, mail and file shares all depend on it. A deleted record or a corrupted zone can take a network down within minutes. This guide shows how to back up DNS zones and server settings on Windows Server 2016–2025 with PowerShell, dnscmd and DNS Manager, how to automate it, and how to restore. There's also a short section for BIND on Linux.
Quick answerBack up every zone with PowerShell. The files are written to C:\Windows\System32\dns\:
Get-DnsServerZone | Where-Object { -not $_.IsAutoCreated -and $_.ZoneType -ne 'Forwarder' } |
ForEach-Object { Export-DnsServerZone -Name $_.ZoneName -FileName "$($_.ZoneName).bak" }
What a complete DNS backup includes
- Zone data: all records (A, AAAA, CNAME, MX, TXT, SRV, PTR) in forward and reverse zones.
- Server settings: forwarders, conditional forwarders, scavenging and recursion settings.
- For Active Directory-integrated zones: the zones live inside AD, so a System State backup of the domain controller is the complete backup. Zone exports are an extra, easy-to-restore copy.
Method 1: Back up DNS zones with PowerShell (recommended)
Run PowerShell as Administrator on the DNS server.
One zone
Export-DnsServerZone -Name "example.com" -FileName "example.com.bak"
All zones, into a dated folder
$date = Get-Date -Format "yyyy-MM-dd"
$dest = "D:\DNS-Backup\$date"
New-Item -ItemType Directory -Path $dest -Force | Out-Null
Get-DnsServerZone | Where-Object { -not $_.IsAutoCreated -and $_.ZoneType -ne 'Forwarder' } | ForEach-Object {
$file = "$($_.ZoneName).bak"
Export-DnsServerZone -Name $_.ZoneName -FileName $file
Move-Item "C:\Windows\System32\dns\$file" "$dest\$file" -Force
}
# server settings (forwarders, scavenging, etc.)
Get-DnsServer | Export-Clixml "$dest\dns-server-settings.xml"
reg export "HKLM\SYSTEM\CurrentControlSet\Services\DNS" "$dest\dns-registry.reg" /y
Export-DnsServerZone always writes to the DNS folder (%windir%\System32\dns), which is why the script moves the files afterwards.
Method 2: Back up zones with dnscmd
dnscmd is still available on current Windows Server versions and is handy in batch scripts:
dnscmd /enumzones
dnscmd /zoneexport example.com backup\example.com.dns
The path is relative to C:\Windows\System32\dns\, so the example writes to C:\Windows\System32\dns\backup\example.com.dns.
Method 3: DNS Manager (GUI) export
- Open DNS Manager (
dnsmgmt.msc). - Expand Forward Lookup Zones and select the zone.
- Right-click it and choose Export List…, then save as
.txtor.csv.
This list is useful for documentation and auditing, but it isn't a zone file. You can't restore from it directly, so use Method 1 or 2 for real backups.
Method 4: System State backup (Active Directory-integrated DNS)
Install-WindowsFeature Windows-Server-Backup
wbadmin start systemstatebackup -backupTarget:E: -quiet
This captures Active Directory together with its DNS zones. Store it on a separate disk or off the server.
Automate daily DNS backups
- Save the script from Method 1 as
C:\Scripts\Backup-DNS.ps1. - Create a scheduled task that runs it every night as SYSTEM:
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\Backup-DNS.ps1" $trigger = New-ScheduledTaskTrigger -Daily -At 2am Register-ScheduledTask -TaskName "DNS Zone Backup" -Action $action -Trigger $trigger -User "SYSTEM" -RunLevel Highest - Copy the backup folder off the server (another server, NAS or object storage), and delete copies older than, say, 30 days.
How to restore a DNS zone
File-backed (standard primary) zone
Copy-Item "D:\DNS-Backup\2026-11-20\example.com.bak" "C:\Windows\System32\dns\example.com.dns"
Add-DnsServerPrimaryZone -Name "example.com" -ZoneFile "example.com.dns" -LoadExisting
Restore as an Active Directory-integrated zone
Restore it as a file-backed zone first (above), then convert it:
ConvertTo-DnsServerPrimaryZone -Name "example.com" -ReplicationScope Domain -PassThru
Finish with Restart-Service DNS, and test with Resolve-DnsName www.example.com -Server localhost.
BIND on Linux: quick backup
sudo rndc freeze # flush dynamic zones to disk
sudo tar czf /backup/bind-$(date +%F).tar.gz /etc/bind /var/lib/bind /var/cache/bind
sudo rndc thaw
Before restoring, validate a zone file with named-checkzone example.com /etc/bind/db.example.com.
Frequently asked questions
Where does Export-DnsServerZone save the file?
Always in C:\Windows\System32\dns\, whatever file name you give it. Move the file afterwards if you want it somewhere else.
How do I back up Active Directory-integrated DNS?
Take a System State backup of a domain controller (wbadmin start systemstatebackup). Also export the zones with PowerShell for quick, single-zone restores.
How often should DNS be backed up?
Daily, plus before any bulk change: migrations, record clean-ups, or changes to scavenging settings.
Can I back up DNS records to a CSV?
Yes. Get-DnsServerResourceRecord -ZoneName example.com | Export-Csv records.csv -NoTypeInformation. That's useful for audits, but use zone exports for restores.


