Solved

script is needed for backing up DNS integrated zones

Posted on 2015-01-23
3
110 Views
Last Modified: 2015-01-26
script is needed for backing up DNS integrated zones
0
Comment
Question by:creative555
[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
3 Comments
 
LVL 7

Accepted Solution

by:
Deadman earned 250 total points
ID: 40567885
Backs up all the DNS zones on a server, including Active Directory-integrated zones. Requires DNSCMD.exe in the current directory or path.

Script in BAT file

@echo off
REM ======================================================================
REM
REM NAME: DNSBackup.bat
REM
REM AUTHOR:
REM DATE  :
REM  
REM    Version: 1.0
REM  
REM COMMENT: Requires DNSCMD.exe in the current directory or in the path.
REM        Will create a backup of all zones hosted local, even AD integrated
REM     zones.  Will auto-create CABS directory where script is
REM        executed from.  This will store .dns (standard primary zone files)
REM        in CAB file.
REM  
REM **DISCLAIMER**
REM    THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
REM    EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE
REM    IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
REM    PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE
REM    EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT
REM    APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY
REM    DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY
REM    USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST
REM    PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON
REM    YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE
REM    EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.  
REM
REM ======================================================================
REM Create Date Variable (US Only) YYYYMMDD
:DATE
For /F "Tokens=2" %%I in ('Date /t') Do Set DTemp=%%I
For /F "Delims=/,= Tokens=2" %%I in ('Set DTemp') Do Set TDate=%%I
For /F "Delims=/,= Tokens=3" %%I in ('Set DTemp') Do Set TDate=%TDate%%%I
For /F "Delims=/,= Tokens=4" %%I in ('Set DTemp') Do Set TDate=%%I%TDate%
Set DTemp=
 
REM Current Directory
set DNSBACKUPPATH=%~dp0
 
REM Default DNS Backup location
set DNSDEFAULTPATH=%systemroot%\system32\dns\
 
REM Directory of where to store DNS Backup Cab files
set CABDIR=%DNSBACKUPPATH%cabs
 
REM Create Directory to store cab files if it does not exist
if not exist %CABDIR% md %CABDIR%
 
REM Create a DATED directory to store today's DNS Backup
if not exist %DNSBACKUPPATH%%TDATE% md %DNSBACKUPPATH%%TDATE%
 
REM CAB directive file (.DDF) needed to cab all files backed up in to one Cab file
Set CABDIRFILE=%DNSBACKUPPATH%%TDATE%\DNSBackup.DDF
 
REM Enumerate primary dns zones, export them, and move them to a dated folder
for /f "tokens=1" %%I in ('dnscmd  /enumzones ^|find /i "primary"') do @dnscmd /zoneexport %%I %%I.%TDATE%.dns >NUL  &  
move %DNSDEFAULTPATH%%%I.%TDATE%.dns %DNSBACKUPPATH%%TDATE%\ >NUL
 
REM Create DDF (cab directive file) heading
echo ;***%COMPUTERNAME% DNS Backup %TDATE% Directive file >%CABDIRFILE%
echo ; >>%CABDIRFILE%
echo .OPTION EXPLICIT >>%CABDIRFILE%
echo .Set CabinetNameTemplate=%COMPUTERNAME%_DNSBackup_%TDATE%.CAB >>%CABDIRFILE%
echo .set DiskDirectoryTemplate=%CABDIR% >>%CABDIRFILE%
echo .Set MaxDiskSize=CDROM >>%CABDIRFILE%
echo .Set FolderSizeThreshold=2000000 >>%CABDIRFILE%
echo .Set CompressionType=MSZIP >>%CABDIRFILE%
echo .Set Cabinet=on >>%CABDIRFILE%
echo .Set Compress=on >>%CABDIRFILE%
 
REM add files to cab'ed to the DDF
for /f %%I in ('dir %DNSBACKUPPATH%%TDATE%\*.dns /b') do @echo %DNSBACKUPPATH%%TDATE%\%%I >>%CABDIRFILE%
 
REM switch to the dated folder and create cab file
cd /d %DNSBACKUPPATH%%TDATE% & makecab /f %CABDIRFILE% /L %CABDIR% >NUL
 
REM switch to script root directory and remove the dated folder and all files
cd /d %DNSBACKUPPATH% & rd /s /q %DNSBACKUPPATH%%TDATE% >NUL


https://gallery.technet.microsoft.com/scriptcenter/5931a49f-e7d0-4d5d-aff4-cb799213b29f#content
0
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 250 total points
ID: 40568195
You can accomplish this using Powershell. Use the powershell script from Jeffrey Hicks Powershell MVP.

Backup DNS using Powershell

Will.
0
 

Author Closing Comment

by:creative555
ID: 40571635
Thank you very much!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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