locked
DNSCMD to backup ALL zones RRS feed

  • Question

  • I need to be able to backup all zones.  we have about 100 zones and we want to use dnscmd.  We are aware of AD integrated zones being backed up but this is the way I've been tasked to do it.
    Tuesday, July 17, 2012 2:53 PM

Answers

All replies

  • Hi,

    To manually backup the DNS zones, just copy the zonename.dns file located at c:\windows\system32\dns


    Thanks and Regards, Mukesh. This posting is provided "AS IS" with no warranties or guarantees , and confers no rights. Please VOTE as HELPFUL if the post helps you and remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Tuesday, July 17, 2012 3:03 PM
  • Hello,

    You can use PowerShell Script.

    Please read this link (read Jeffery Hicks MVP suggestion):

    Powershell Script :How to Backup DNS Zones

    PowerShell Script : How to Backup DNS Zones – Improved

    And, here is restore PowerShell Script:

    Powershell Script – How to Restore DNS Zones

    Regards




    • Edited by Patris_70 Tuesday, July 17, 2012 4:18 PM restore PowerShell Script link
    • Proposed as answer by Meinolf Weber Tuesday, July 17, 2012 5:09 PM
    • Marked as answer by Awinish Wednesday, July 18, 2012 9:35 AM
    Tuesday, July 17, 2012 4:13 PM
  • Hi Gene,

    Thanks for posting here.

    So may I know are all these 100 zones are AD integrated or standalone DNS zones ?

    Standalone DNS zone can be backed up by the method Mukesh posted about directly copy the DNS database file and since AD integrated zone is contained by AD database so the AD backup-restore will achieve that .

    Anyway , we has a sample script which is similar like Patris_70 posted that will help to simplify the backup process , DNScmd.exe will also be used :

    Backup DNS Zones

    http://gallery.technet.microsoft.com/scriptcenter/5931a49f-e7d0-4d5d-aff4-cb799213b29f

    Regards,

    Tiger Li

    TechNet Subscriber Support in forum

    If you have any feedback on our support, please contact  tnmff@microsoft.com.


    Tiger Li

    TechNet Community Support

    • Proposed as answer by Sandesh Dubey Wednesday, July 18, 2012 4:13 AM
    • Marked as answer by Awinish Wednesday, July 18, 2012 9:35 AM
    Wednesday, July 18, 2012 2:51 AM
  • Backing up primary and secondary zones independent of the system state is a pretty simple process. You can use the xcopy command to back up all zone text files on a DNS server. This command would back up the contents of the default DNS folder to the "C:\dnsbk" folder:

    xcopy %systemroot%\system32\dns c:\dnsbk /y

    However, for Active Directory Integrated Zones, its a little more tricky. You need to use dnscmd.exe. You will need to use the /zoneexport switch of the command. The syntax of the command is:
     
    DnsCmd <ServerName> /ZoneExport <ZoneName> <ZoneExportFile>   <ZoneName>   -- FQDN of zone to export  /Cache to export cache

    For example, to backup nwtraders.msft zone, you
    dnscmd /zoneexport nwtraders.msft backup\nwtraders.msft.bak

    Taken from: http://sgwindowsgroup.org/forums/t/50.aspx 

    DNS Backups Without the Baggage
    http://mcpmag.com/articles/2005/07/05/dns-backups-without-the-baggage.aspx

    Hope this helps


    Best Regards,

    Sandesh Dubey.

    MCSE|MCSA:Messaging|MCTS|MCITP:Enterprise Adminitrator | My Blog

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Wednesday, July 18, 2012 4:15 AM
  • One more link for you reference.

    http://blogcastrepository.com/blogs/mattbro/archive/2006/03/09/691.aspx


    Awinish Vishwakarma - MVP - Directory Services

    My Blog: awinish.wordpress.com

    Disclaimer This posting is provided AS-IS with no warranties/guarantees and confers no rights.

    Wednesday, July 18, 2012 9:37 AM
  • I would like to add some improvements to the Backup Script.

    This modifications allows to use a shared folder to drop the backup objetcs.

    The comments are in spanish

    #——————————————————————————————-#

    #– Definicion de variables——#

    #Obtener nombre del server con variable de entorno

    $DNSSERVER=get-content env:computername

    #—Definir carpeta donde guardar el backup—–#
    $BkfFolder=”\\contoso.com\bkp_dns”
    $BkpDefaltFolder="c:\windows\system32\dns\backup"

    #—Definir archivo donde guardar las configuraciones de DNS
    $ArchivoConfig=Join-Path $BkfFolder “input.csv”

    #—-Verifica si existe la carpeta. Si existe borra el contenido–#
    if (-not(test-path $BkfFolder)) {
    new-item $BkfFolder -Type Directory | Out-Null
    } else {

    Remove-Item $BkfFolder”\*” -recurse
    }

    #—- Obtiene configuraciones de DNS atraves de WMI ——–#

    $lista = get-WmiObject -ComputerName $DNSSERVER -Namespace root\MicrosoftDNS -Class MicrosoftDNS_Zone

    #—-Exporta la informacion y la escribe en el archivo escrito en la variable $ArchivoConfig —#

    $lista | Select Name,ZoneType,AllowUpdate,@{Name=”MasterServers”;Expression={$_.MasterServers}},DsIntegrated | Export-csv $ArchivoConfig -NoTypeInformation

    #— Llamada a DNSCMD para exportar todas las zonas
    $lista | foreach {
    $path=”backup\”+$_.name
    $cmd=”dnscmd {0} /ZoneExport {1} {2}” -f $DNSSERVER,$_.Name,$path
    Invoke-Expression $cmd
    }

    #- Mueve todos los items de la carpeta por defecto al servidor de archivos

    copy-item $BkpDefaltFolder -destination $BkfFolder -recurse -verbose

    #-Remueve los archivos de la carpeta .\dns\backup del S.O.

    Remove-Item $BkpDefaltFolder”\*” -recurse


    #Fin del script
    #——————————————————————————————-#

    Tuesday, May 26, 2015 7:29 PM