Re: Backup bat file

From: Lanwench [MVP - Exchange] (lanwench_at_heybuddy.donotsendme.unsolicitedmail.atyahoo.com)
Date: 05/17/04


Date: Sun, 16 May 2004 23:38:23 -0400

TRD wrote:
> I am trying to use the built in program to run scheduled backups. I am
> trying to use a bat file to make the backup run and backup directly
> to the dds 4 tape drive. I have seen the page on smallbizserver.net
> on backing up the server. But I can't create a backup file on the
> server as there is not enough room so I would like to change the bat
> file to backup directly to the dat drive. Has anyone done this? If so
> can I get a sample bat or point me where I can get this to work.
>
> TIA
>
> TRD

Here's what I use...and as usual, MANY thanks to the kindly fellow I cribbed
it from. You'll need to make lots of changes to suit your environment - your
tape library, media type, etc.... Save your NTBackup job settings as a .bks
file and reference it in the batch file - it will also let you e-mail a copy
of the logs if you install BLAT (google it - freeware). Mind word wrap@

--------------------------------------------

title SERVERNAME Full Nightly Backup Job

rem ---------------------- REFRESH DRIVE -----------------

rem Run rsm view /tlibrary to find out the proper name...and
rem you'll need sleep.exe from the resource kit. This file presumes
rem a Dell PowerVault DLT drive....and SP4 on W2k to enable
rem the inventory command.

rsm.exe inventory/LF"Dell (TM) PowerVault (TM) 110T DLT1 Drive" /AFULL
sleep 30

rem ---------------------- VARIABLES ----------------------

rem clear variable contents
set srvname=
set notify=
set notifycc=
set bkdir=

rem ***set server name****

set srvname=SERVERNAME

rem ***set server name****

rem ***set working dir******
rem make sure you set this to what you want
set bkdir=e:\backups

rem ***set working dir******

rem ***set person/group to notify***
set notify=address@domain.com
rem set notifycc=another.person@domain.com
rem ***set person/group to notify***

rem clear variable contents
set tm=
set rtm=
set dt=
set label=

if "%srvname%"=="" goto END
if "%bkdir%"=="" goto END
if "%notify%"=="" goto END
goto BEGIN

:BEGIN
rem **** set date, time, and label variables
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
for /f "Tokens=1" %%i in ('time /t') do set rtm=%%i
set tm=%tm::=-%
set label=full-%srvname%-%dt%%tm%m

rem ---------------------- JOB EXECUTION SECTION ----------------------

rem The backup job here is obviously called backup.bks - it's a job set up
rem in NTBackup that also includes the Exchange stores, etc....
rem You'll need to set the media type to DLT or DDS or whatever it is

C:\WINNT\system32\NTBACKUP.EXE backup "@%bkdir%\backup.bks" /n "%label%" /d
"full" /v:yes /r:no /rs:no /hc:on /m normal /j "full" /l:s /p "DLT" /um

rem ---------------------- EJECT TAPE AFTER BACKUP ----------------------

rsm eject /PF"%label% - 1" /astart

rem ---------------------- LOG AND NOTIFICATION
SECTION ----------------------

rem **** Here, the logs are copied out of the default "userprofile"
rem **** folder, and placed in the working dir set above. Afterwards, the
most recently modified log file
rem **** will be email via blat.exe to those listed in the "notify" section
above.

if not exist %bkdir%\logs mkdir %bkdir%\logs
copy "%userprofile%\Local Settings\Application Data\Microsoft\Windows
NT\NTBackup\data\backup*.log" %bkdir%\logs
for /f "eol=g" %%i in ('dir %bkdir%\logs\*.log /od /b') do echo %%i >
%bkdir%\_logtemp
for /f %%i in (%bkdir%\_logtemp) do set logfile=%%i

echo Full backup completed on %dt% at %rtm%m > %bkdir%\_notify.txt
echo You may check the attached log to verify that it was successful. >>
%bkdir%\_notify.txt
echo Please report any errors to the administrator >> %bkdir%\_notify.txt
echo. >> %bkdir%\_notify.txt
echo ****************************************************************** >>
%bkdir%\_notify.txt
echo Remove the tape and label it with the appropriate name. >>
%bkdir%\_notify.txt
echo Insert the following night's tape. >> %bkdir%\_notify.txt
echo Please note: If tape is not changed, the BACKUP WILL NOT occur, >>
%bkdir%\_notify.txt
echo and there is a possibility that previous data will be overwritten. >>
%bkdir%\_notify.txt
echo ****************************************************************** >>
%bkdir%\_notify.txt
echo. >> %bkdir%\_notify.txt
echo -Administrator >> %bkdir%\_notify.txt

rem Make sure you have BLAT installed!

blat %bkdir%\_notify.txt -mime -t address@domain.com -cc
"%notifycc%" -subject "Backup Logs for %srvname%" -f
fromaddress@domain.com -attach %bkdir%\logs\%logfile%

del %bkdir%\_notify.txt
del %bkdir%\_logtemp

goto END

:END
cls
exit



Relevant Pages

  • Re: Batch ntbackup to external hard drives (new version - Sept 2006)
    ... Below is a new version of the backup script that I posted to USENET ... external hard drives, such as those available from AcomData and others). ... echo Runs a backup to two external hard drives and logs progress and errors ... rem 1) Edit the Script Customizations ...
    (microsoft.public.windows.server.general)
  • RE: NT Backup inconsistent medium
    ... I would configure the backup with NTBackup and set a schedule from there. ... | directory's to a tape with NT backup it works fine. ... | @ECHO Off ... | REM Script gebaseerd op NT Backup ...
    (microsoft.public.windows.server.sbs)
  • RE: NT Backup inconsistent medium
    ... directory's to a tape with NT backup it works fine. ... REM Script gebaseerd op NT Backup ... REM Tape dient unieke naam te hebben, ... ECHO Start backup procedure ...
    (microsoft.public.windows.server.sbs)
  • Re: dos batch programmer help!!
    ... REM Set up your two serial numbers here and ensure dir C:\TEMP\ exists ... if errorlevel 1 goto otherdisk ... echo Wrong diskin H: -- swap it to allow backup to continue! ...
    (comp.os.msdos.programmer)
  • Re: dos batch programmer help!!
    ... echo Please install the backup tape ... if exist testtape.ok goto goodtape ... echo ERROR ERROR ERROR ...
    (comp.os.msdos.programmer)