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


Leave a Comment:


Search

Categories

android x 1
apache x 1
apple x 4
backup x 2
cygwin x 1
dns x 1
dos x 1
drupal x 3
ftp x 1
iis x 1
imap x 1
linux x 22
mail x 4
mysql x 3
oracle x 1
pop3 x 1
print x 2
proxy x 1
rsync x 1
shell x 8
smtp x 1
squid x 1
ssh x 1
storage x 2
web x 3
windows x 15

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!