DNSexport.CMD

10:36 PM

@echo off
 
:: ===================================================================================================
::
::          Name: dnsexport.cmd
::   Description: Windows DNS script for backing up data from standalone DNS zones
::    Written By: Aslam latheef
::          Date: 6/17/2010
::
::  Script Usage: dnsexport.cmd
::   Result Code: N/A
::       Example: D:\Windows\Scripts\dnsexport.cmd
::
::
::  *** Notes ***
::
::  1) The dnsexport.cmd script is for standalone DNS servers which need a backup of all relevant DNS
::     zone data.
::  2) This script relies on the Windows DNS tool dnscmd.exe and 7-Zip installed in their default
::     directories to be run successfully
::  3) This check does not check for slowness on the line; Only if an ICMP reply is received
::  4) You can customize the INFORMATION and ERROR message if you need to in the variable section below
::  4) For more information or help, please email corp-tech@opsource.net
::
:: ===================================================================================================
 
:: Sets help variable
set HELPMSG=/?
 
:: Checks for help argument being passed
IF "%1" == "%HELPMSG%" GOTO USAGE
IF "%1" == "" GOTO USAGE
 
:: Set DNS Server export save path
set SAVEPATH01=\\servername\sharename
set SAVEPATH02="D:\Backup"
 
 
: Create variable for date and time for zip file creation
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
 
:: ===================================================================================================
::
::  *** WARNING - DO NOT MODIFY!!! ****
::
::  Please do not modify the code below this section as that can cause the script to fail or perform
::  in an unintended manner. If you decide to anyways, do at your own risk.
::
:: ===================================================================================================
 
: Delete original DNS Zone dump files
del C:\WINDOWS\system32\dns\export\*.dns /f
 
: Create DNS Zone dump files; Second part of the script copies files to a subdirectory that must be present called "export"
dnscmd /zoneexport corp.opsource.net export\apps.corp.opsource.net.dns
dnscmd /zoneexport 0.10.in-addr.arpa export\0.10.in-addr.arpa.dns
 
: Zip DNS files up for mailing
"D:\Program Files\7-Zip\7z" u C:\WINDOWS\scripts\dnsexport_%mydate%_%mytime%.zip c:\windows\system32\dns\export\* -tzip
 
: Copy file onto AD server for replication and redundancy
xcopy /vy "D:\WINDOWS\scripts\dnsexport_%mydate%_%mytime%.zip" %SAVEPATH01%
REM xcopy /vy "D:\WINDOWS\scripts\dnsexport_%mydate%_%mytime%.zip" %SAVEPATH02%
del /q "D:\WINDOWS\scripts\dnsexport_%mydate%_%mytime%.zip"
 
: Pause the script for a few seconds for interactive runs and to display the screen to the end user:
"D:\Program Files\opsbin\sleep.exe" 5
 
:USAGE
 
echo.
echo *** Usage ***
echo.
echo   Script Usage: dnsexport.cmd
echo        Example: D:\Windows\Scripts\pingcheck.cmd
echo.
echo For more information on the script contents please read the remarks
echo at the top of this batch file.

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results