Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active June 12, 2025 12:09
Show Gist options
  • Save magnetikonline/aa31a78cb0bae201b2335428cfaba9b3 to your computer and use it in GitHub Desktop.
Save magnetikonline/aa31a78cb0bae201b2335428cfaba9b3 to your computer and use it in GitHub Desktop.
Microsoft DNS server - backup and restore AD integrated zone.

Microsoft DNS server - backup and restore AD integrated zone

Firstly, backup the existing zone to a zone file. Resulting file will always be placed in C:\Windows\system32\dns - this can't be controlled:

$ dnscmd /zoneexport myzone.com myzone-backup-file.zone

To restore the zone, firstly move our myzone-backup-file.zone file back into C:\Windows\system32\dns, then:

$ dnscmd /zoneadd myzone.com /primary /file myzone-backup-file.zone /load

Finally, convert DNS local primary zone to an AD integrated zone (stupidly, this must be done over two commands):

$ dnscmd /zoneresettype myzone.com /dsprimary

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment