Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3044
  • Last Modified:

Backing Up a Primary DNS Server with PowerShell

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
mattheweharding
Asked:
mattheweharding
  • 2
  • 2
  • 2
1 Solution
 
Rob StoneCommented:
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
 
matthewehardingAuthor Commented:
I've tried that script on Server 2012, and didn't work.
0
 
SubsunCommented:
See example 1 from following article..
http://technet.microsoft.com/en-us/library/jj649845.aspx
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
matthewehardingAuthor Commented:
Same problem with that script. Only the conditional forwarders are created. Not the forward and reverse lookup zones.
0
 
SubsunCommented:
Are you getting ay warning or Error?
0
 
Rob StoneCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now