Backup and restore AD Integrated DNS Zones

Posted: February 10, 2011 in DNS, Scripts

Some quick Powershell to do backup and restore of AD DNS zones. You need the reskit installed as a pre-req. Backup files are placed into c:\windows\system32\dns + whatever you specify. There doesn’t appear to be a way to change the base folder though.

Backup

$records = Import-CSV c:\scripts\zones.csv

foreach ($DNSRecord in $records){
$zone = $DNSRecord.Name
Write-Host $zone
Start-process c:\reskit\dnscmd “/zoneexport $zone backup\cmr\$zone.bak”
}

Restore

$records = Import-CSV c:\scripts\$list.csv

foreach ($DNSRecord in $records){
$zone = $DNSRecord.Name

Start-process c:\reskit\dnscmd “/zoneadd $zone /primary /file backup\cmr\$zone.bak /load”
Read-Host ‘Press enter once DNS import is complete’
Start-process c:\reskit\dnscmd “/zoneresettype $zone /dsprimary”
Read-Host ‘Press enter once DNS changes are complete’
Start-process c:\reskit\dnscmd “/config $zone /allowupdate 2”
}

Advertisements
Comments
  1. This blog post, “Backup and restore AD Integrated DNS Zones
    Virtual Technology Solutions Tech Spot” was in fact excellent.
    I am printing out a clone to demonstrate to my close friends.

    Thanks a lot,Hildegard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s