Migrating all dns zones faster

written by Admin

Posted on 2014-09-18


I need to migrate all dns zone fron an old windows 2000/2003/2008 server to a new Windows 2008-R2/2012-R2 server. The servers are stand-alone and I cannot login on a same domain or from one to the other (no remote dnscmd command possible) ...and I have little time to complete the migration.


Start dumping all zones on the older server.
Create a compressed archive of the zone files and move it on the newer server.
Load all zones on the newer server.

To save all zones to disk:
@echo off
for /f "usebackq delims= " %%i in (`dnscmd /EnumZones ^| find "Secondary"`) do call :DOZONE %%i goto end
dnscmd /ZoneExport %1 %1.dns

To reload all zones from disk:
@echo off
for /f "usebackq delims=|" %%f in (`dir /b "C:\Windows\System32\DNS" ^| findstr /i dns`) do call :DOZONE %%f
set _t=%1
set _d=%_t:~0,-4%
echo %_d%
dnscmd /ZoneAdd %_d% /Secondary /file C:\Windows\System32\DNS\%_d%.dns

Here I'm migrating a Secondary DNS Server, if you need to migrate Primary DNS Zones you only need to substitute the strings 'Secondary' with 'Primary' (and remove the IP address after the word 'Secondary'). I also assume that you know how to move a zip file from a server to another (network, usb-drive, etc).



Leave a Comment:



We need collaboration and a real boost from our community: write us an email for every trick you find!

This website is a sysadmin swiss-knife for every-day Windows, Linux and Mac administration and troubleshooting

Our database grows if YOU send us your tips and trick as soon as you find them every day!