NTBackup Script Procedure

1)      Copy robocopy.exe from the Resource Kit to something like c:\backup\tools. This is used in step 5 below.


2)      Create a backup list using the GUI version. Save a system state only as night.bks, save all the drives and system state as night-all.bks. Make sure you use the backup directory path listed below in the script or modify to a SAN location.


3)      Use the follow for the required .bat file


C:\backup\tools\nightlybackup.bat:


            *** BEGIN BAT FILE ***


@ECHO OFF


REM


REM  Build Date String yyyymmddhhmm


REM


for /F “usebackq tokens=2″ %%i IN (`DATE /T`) DO Set TIMESTR=%%i%


for /F “usebackq tokens=1,2,3 delims=/” %%i IN (‘%TIMESTR%’) DO SET MONTH=%%i%


for /F “usebackq tokens=1,2,3 delims=/” %%i IN (‘%TIMESTR%’) DO SET DAY=%%j%


for /F “usebackq tokens=1,2,3 delims=/” %%i IN (‘%TIMESTR%’) DO SET YEAR=%%k%


for /F “usebackq” %%i IN (`Time /T`) DO Set TIMESTR=%%i%


for /F “usebackq tokens=1,2* delims=:” %%i IN (‘%TIMESTR%’) DO SET HOUR=%%i%


for /F “usebackq tokens=1,2* delims=:” %%i IN (‘%TIMESTR%’) DO SET MINUTE=%%j%


SET DIRSTR=%YEAR%%MONTH%%DAY%%HOUR%%MINUTE%


SET TIMESTR=


SET MONTH=


SET DAY=


SET YEAR=


SET HOUR=


SET MINUTE=


@ECHO Directory String %DIRSTR%


 


IF NOT EXIST “c:\backup\tools\nightlybackup.bat” GOTO SKIP


 


C:\WINDOWS\system32\ntbackup.exe backup “@\\DOMAINCONTROLLERNAME\c$\Backup_DCNAME\night-all.bks” /n “DCNAME.bkf” /d “Nightly” /v:yes /r:no /rs:no /hc:off /m normal /j “Nightly” /l:s /f “\\DOMAINCONTROLLERNAME\C$\Backup_DCNAME\%DIRSTR%DCNAME.bkf


 


EXIT


 


:SKIP


 


C:\WINDOWS\system32\ntbackup.exe backup “@\\DOMAINCONTROLLERNAME \c$\Backup_DCNAME \night.bks” /n “DCNAME.bkf” /d “SS_Nightly” /v:yes /r:no /rs:no /hc:off /m normal /j “SS_Nightly” /l:s /f “\\DOMAINCONTROLLERNAME\C$\Backup_DCNAME\%DIRSTR%DCNAME.bkf


 


EXIT


            *** END BAT FILE ***


 


Comments and legend for the above batch file.


 


First I turn of echo


Next section builds the current date, we will use this to sort the backup and delete ones older than 7 days.


If not exist statement is useful if you store anything on a SAN drive. If they SAN is down normally the backup will fail, so I check before and then just run night to just backup the system state.


First backup runs a backup of the DOMAINCONTROLLERNAME (replace with a real name), creates a new file called DCNAME.bkf (replace with server name), next I label the backup Nightly, verify is then turned on, restricted access is NOT turned on – you may want it though (so /r:yes would turn it on), hardware compression is turned off, the backup type is set to normal, next the job name is set for backup reporting, next logging is set to summary, and finally the file name is created with the date and time stamp at the front (again for sorting and deleting older files later).


 


4)       To schedule a task to automatically backup a machine. Go to Start-> Control Panel -> Scheduled Tasks -> Add Scheduled Task.  During the configuration the following options are selected:


 


Scheduled Task Wizard

Next

Scheduled Task Wizard

Application

 

Browse

C:\backup\tools\nightlybackup.bat

Open

Scheduled Task Wizard

Type a name for this task

Perform this task

 

Nightly

Daily

Next

Scheduled Task Wizard

Start Time

Perform this task

Start date

 

3:15 AM

Every Day

(today)

Next

Scheduled Task Wizard

Enter the user name

Enter the password

Confirm password

 

 

 

Next

Scheduled Task Wizard

Open advanced…

 

Unchecked

Finish


 


5)      Finally I use robocopy to clean up, so the backup won’t fill up the disk.


c:\backup\tools\robocopy c:\backup\ c:\backup\t *.bkf /MOV /MINAGE:10 rd /q /s c:\backup\t


I use Robocopy to look at the c:\backup and create a c:\backup\t folder (for temporary). I look for anything that ends with .bkf which is then Moved to the temporary (c:\backup\t) folder, if it is at least 10 days old. This process is done quietly and uses a sub directory of c:\backup\t.


 


Enjoy, let me know if you have any questions or issues.

5 thoughts on “NTBackup Script Procedure”

  1. There’s a simpler way to create date and time based files using the built in %DATE% and %TIME% variables:

    @ECHO OFF
    SETLOCAL
    REM ECHO %DATE%
    REM ECHO %TIME%
    SET _Year=%DATE:~10,4%
    SET _Month=%DATE:~4,2%
    SET _Day=%DATE:~7,2%
    IF /I “%TIME:~0,1%” == ” ” (
    SET _Hour=0%TIME:~1,1%
    ) ELSE (
    SET _Hour=%TIME:~0,2%
    )
    SET _Minute=%TIME:~3,2%
    SET _Second=%TIME:~6,2%

    SET _FileName=%_Year%%_Month%%_Day%%_Hour%%_Minute%

    SET _
    ENDLOCAL

    The only tricky part is parsing the hour field.

    SETLOCAL and ENDLOCAL are also usefull for removing the vars you set in a batch file.

  2. Whether we approve it or not, formerly in our lives, we would obligate to carry out term papers and other written . It is explicitly not basic but very elegant to construct a analyze about this good topic. To do that, you need to read many of articles and books, or you can just order some kind of work and then use plagiarism checking accomplished by http://www.plagiarismsearch.com and save your time like some quick help with the American Dream.

  3. Thanks for the backup script, looks really nice! I will give it a try.

    Question though, as i understand you are only moving backup files older than 10 days but you are not doing anything with them like clean up or delete them?

  4. Thanks for the backup script, looks really nice! I will give it a try.

    Question though, as i understand you are only moving backup files older than 10 days but you are not doing anything with them like clean up or delete them?

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>