Migrating all dns zones faster

written by Admin


Posted on 2014-09-18


Problem

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.

Solution

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 127.0.0.1 /EnumZones ^| find "Secondary"`) do call :DOZONE %%i goto end
:DOZONE
dnscmd 127.0.0.1 /ZoneExport %1 %1.dns
:end

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
:DOZONE
set _t=%1
set _d=%_t:~0,-4%
echo %_d%
dnscmd 127.0.0.1 /ZoneAdd %_d% /Secondary 81.72.219.50 /file C:\Windows\System32\DNS\%_d%.dns
:end

P.S.
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).

Feedback


Comments

Leave a Comment:

Search

Welcome

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!