Solved

Backing Up a Primary DNS Server with PowerShell

Posted on 2013-06-28
6
2,500 Views
Last Modified: 2013-07-05
I'm attempting to backup a primary, non-Active Directory, DNS server with PowerShell. It's a Windows Server 2012 Standard server with all of the updates applied, and only the DNS role installed.  I found the code from this TechNet example.

#Get DNS Server configuration and store it in ServerConfig.xml 
Get-DnsServer | Export-Clixml -Path ServerConfig.xml 

Open in new window


This part worked great, and spit everything out into an XML file. I ran through the file, and verified that all of the forward lookup zones, reverse lookup zones, and conditional forwarder zones were there.

I attempted to restore the XML configuration to another Windows Server 2012 Standard server with the DNS role installed using the restore command.

#Import the configuration from ServerConfig.xml and set it on TargetServer through CimSession 
Import-Clixml -Path ServerConfig.xml | Set-DnsServer –CimSession TargetServer

Open in new window


The problem is only the conditional forwarder zones were restored. The forward lookup zones and reverse lookup zones didn't transfer.

Is there something I'm missing?
0
Comment
Question by:mattheweharding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Rob Stone
ID: 39285701
It's stating that it is only backing up the server configuration, not the zone's.

This link has a PS script to backup the DNS zones:
http://c-nergy.be/blog/?p=1837

Restore DNS zones:
http://c-nergy.be/blog/?p=1858

If you just want to copy the zone's over, you can take a copy of the DNS file in %systemroot%\system32\dns and copy that to the other DNS server.
0
 

Author Comment

by:mattheweharding
ID: 39285708
I've tried that script on Server 2012, and didn't work.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39286084
See example 1 from following article..
http://technet.microsoft.com/en-us/library/jj649845.aspx
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:mattheweharding
ID: 39290005
Same problem with that script. Only the conditional forwarders are created. Not the forward and reverse lookup zones.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39300817
Are you getting ay warning or Error?
0
 
LVL 15

Accepted Solution

by:
Rob Stone earned 500 total points
ID: 39301543
This also works, although it's a bit cumbersome:

Exported a zone using the following cmdlet
Export-DnsServerZone -Name zonename.local -FileName ZonenameExport.local.dns

This exported the file to C:\Windows\System32\DNS.

I then copied the file to another DNS server, renamed it to Zonename.local.dns and ran the following command:
DNSCMD /ZoneAdd Zonename.local /Primary /File Zonename.local.dns /load

This then loaded the zone and records into DNS.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
In this Micro Tutorial viewers will learn how to restore their server from Bare Metal Backup image created with Windows Server Backup feature. As an example Windows 2012R2 is used.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question