Schedule a batch file with parameters containing spaces up vote 0 down vote favorite I need to schedule a task in Windows Server 2003 that executes this script that deletes files older that n days in the specified folder.

  1. Exchange Server 2003 Backup
  2. Windows Server 2003 Backup Software

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

Exchange Server 2003 Backup

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:winntsystem32ntbackup.exe

You should modify the following items in the script:

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

I:server04server04-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.

Schedule Server 2003 Backup Batch File

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).

Windows Server 2003 Backup Software

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:

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:{yesno}] [/R:{yesno}] [/L:{fsn}] [/M {BackupType}] [/RS:{yesno}] [/HC:{onoff}] [/SNAP:{onoff}]

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:{yesno}
Verifies the data after the backup is complete.
/R:{yesno}
Restricts access to this tape to the owner or members of the Administrators group.
/L:{fsn}
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:{yesno}
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:{onoff}
Uses hardware compression, if available, on the tape drive.
/SNAP:{onoff}
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.
Posted on  by  admin