A command line script was needed to backup the systemstate of Windows 2003 domain controller with the builtin Microsoft NTBackup utility called ntbackup.exe. The thebackroomtech has a respectable example of such a script from which I have created a modified version to better suit our requirements.
This script was created to backup a Windows 2003 domain controller systemstate. To break the script down, the first line is a remark that does not get processed. The second and third lines breakdown and reorganize the date and time command outputs to a format that is useful for this script. The results of the date and time are combined together on the fourth line. The fifth line executes the ntbackup command with it’s predefined variables to a partially dynamically generated filename.
:: The following produce the date dt=YYYY-MMDD and time tm=HHMM for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%l-%%j%%k for /f "tokens=1-4 delims=: " %%i in ('time /t') do set tm=%%i%%j set state=%dt%-%tm% C:\WINDOWS\system32\ntbackup.exe backup systemstate /v:yes /r:no /rs:no /hc:off /j "System State Backup" /l:f /f "C:\%computername%-system-state-%state%.bkf"
Upon execution of the script, a file will be created on the C drive. An example, MYDCSERVER-system-state-2011-0216-1142.bkf.
To take it a step further, the script can be used as a scheduled task.
- Navigate to Add Scheduled Task
Start > Control Panel > Scheduled Task > Add Scheduled Task
Follow the instructions to create your scheduled task.