Here’s a simple batch file script to backup the Windows Server 2003 System State to a removable drive:

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
 set tm=%tm::=-%
 set dtt=%dt%%tm%

C:\WINDOWS\system32\ntbackup.exe backup systemstate /v:yes /r:no /rs:no /hc:off /m normal /j "server04 system state backup to I" /l:f /f "I:\server04\server04-system-state-%dtt%.bkf"

Save the script as ssbackup.bat (or whatever name you choose). If you are running the script on a Windows 2000 server, change the path to ntbackup.exe to c:\winnt\system32\ntbackup.exe

Table of Contents

    You should modify the following items in the script:

    server04 system state backup to I – This is the backup description.

    I:\server04\server04-system-state-%dtt%.bkf – this is the path to save the backup file to and file name. My file is saved to the I:\server04 directory.

    I used ssgsergio’s script as my basis for the first part of the script – I never can remember the syntax for using the day-date-time variables (%dtt% in this case).

    The inspiration for the second part of the script came from KB 239892, ntbackup help, and looking at the properties of backup I already had setup – you can see these details in Control Panel – Scheduled Tasks, assuming you have a backup already scheduled.

    If you’d like explanations of what all the command line options for ntbackup.exe are, from a command prompt run:

    ntbackup.exe /?

    The ntbackup syntax is:

    Syntax

    ntbackup backup [systemstate] @FileName.bks” /J {JobName} [/P {PoolName}] [/G {GUIDName}] [/T {TapeName}] [/N {MediaName}] [/F {FileName}] [/D {SetDescription}] [/DS {ServerName}] [/IS {ServerName}] [/A] [/V:{yes | no}] [/R:{yes | no}] [/L:{f | s | n}] [/M {BackupType}] [/RS:{yes | no}] [/HC:{on | off}] [/SNAP:{on | off}]

    Parameters

    systemstate
    Specifies that you want to back up the System State data. When you select this option, the backup type will be forced to normal or copy.
    @FileName.bks
    Specifies the name of the backup selection file (.bks file) to be used for this backup operation. The at (@) character must precede the name of the backup selection file. A backup selection file contains information on the files and folders you have selected for backup. You have to create the file using the graphical user interface (GUI) version of Backup.
    /J {JobName}
    Specifies the job name to be used in the backup report. The job name usually describes the files and folders you are backing up in the current backup job.
    /P {PoolName}
    Specifies the media pool from which you want to use media. This is usually a subpool of the Backup media pool, such as 4mm DDS. If you select this you cannot use the /A, /G, /F, or /T command-line options.
    /G {GUIDName}
    Overwrites or appends to this tape. Do not use this switch in conjunction with /P.
    /T {TapeName}
    Overwrites or appends to this tape. Do not use this switch in conjunction with /P.
    /N {MediaName}
    Specifies the new tape name. You must not use /A with this switch.
    /F {FileName}
    Logical disk path and file name. You must not use the following switches with this switch: /P /G /T.
    /D {SetDescription}
    Specifies a label for each backup set.
    /DS {ServerName}
    Backs up the directory service file for the specified Microsoft Exchange Server.
    /IS {ServerName}
    Backs up the Information Store file for the specified Microsoft Exchange Server.
    /A
    Performs an append operation. Either /G or /T must be used in conjunction with this switch. Do not use this switch in conjunction with /P.
    /V:{yes | no}
    Verifies the data after the backup is complete.
    /R:{yes | no}
    Restricts access to this tape to the owner or members of the Administrators group.
    /L:{f | s | n}
    Specifies the type of log file: f=full, s=summary, n=none (no log file is created).
    /M {BackupType}
    Specifies the backup type. It must be one of the following: normal, copy, differential, incremental, or daily.
    /RS:{yes | no}
    Backs up the migrated data files located in Remote Storage. The /RS command-line option is not required to back up the local Removable Storage database (that contains the Remote Storage placeholder files). When you backup the %systemroot% folder, Backup automatically backs up the Removable Storage database as well.
    /HC:{on | off}
    Uses hardware compression, if available, on the tape drive.
    /SNAP:{on | off}
    Specifies whether or not the backup should use a volume shadow copy.
    /M {BackupType}
    Specifies the backup type. It must be one of the following: normal, copy, differential, incremental, or daily.

    Leave a Reply

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