Batch files to automate rolling full and incremental backups with Win. Task Scheduler

Discussion in 'Acronis True Image Product Line' started by The Gold Tooth, Aug 16, 2008.

Thread Status:
Not open for further replies.
  1. The Gold Tooth

    The Gold Tooth Registered Member

    Joined:
    Feb 25, 2008
    Posts:
    27
    INTRODUCTION: I recently posted to this board the batch files I use to automate the creation of rolling, 3-generation weekly full and incremental drive images using True Image (TI) and its Pre/Post Command facility. The backup jobs were scheduled and executed by TI. Unfortunately, as I and others have discovered, the TI scheduler is an unreliable beast, unaccountably "forgetting" to run scheduled jobs and leaving no trail that it ever attempted to do so. Failing to run a scheduled backup is unacceptable, so I looked into alternatives.

    In this message I present a solution that uses the Windows Task Scheduler (WTS) instead of TI to schedule the execution of backup jobs invoked by batch files. This posting will make more sense if you first read my earlier message. I thank the many contributors to this forum from whose work I draw for the solution I present here.

    NOTES:

    1. The new method requires only two backup jobs (Full and Incremental) to be defined in TI rather than the previous three (Full, Incremental, and Incremental Monday), and uses only two batch files rather than the previous four.

    2. The previous method used the TI scheduler to execute backup jobs that had been configured to invoke batch files both before and after their execution using TI's Pre/Post Command facility. The new method uses WTS to execute batch files that contain the instructions required to invoke TI from the command line. In other words, the old way used TI to run batch files; the new way uses batch files to run TI.

    3. Having discovered that ProcessIdleTasks is an asynchronous process, I have inserted in the new batch files a wait of 5 minutes (300 seconds) after issuing the command in order to increase the likelihood that it will have completed operations before the next command in the batch file is executed. Windows XP does not by default include the executable SLEEP.EXE I use to invoke the wait, but is can be downloaded as part of the free Windows Server 2003 Resource Kit Tools from Microsoft (don't worry about "Server" in the name, the download is for XP clients also).

    4. The instruction to execute TI from the command line takes the general form "Path for TI executable\TI executable" /script: "Path for saved TI backup task\TI backup task". Some messages on this forum specify no space between "/script:" and the name of the TI task file. I don't know whether this works, but I know it works with a space.

    5. TI saves task files under impenetrable (at least to me) names composed of mixed alphabetic and numeric characters and hyphens, e.g. 0AC88121-1194-44CF-8541-0F91FD023190.tib.tis. To find out the "real" name of the task a file represents (i.e., the name you gave the task in TI), open the file with a text editor; the unencrypted name of the task is visible near the top of the data.

    6. For clarity, I have renamed the Second Copy backup profile group "Mass Backups" to "Backup Sync" and changed the order of some of the directory maintenance commands in the weekly batch file.

    7. I have configured WTS to execute WeeklyBackup.bat at 1:30 on Monday mornings, and DailyBackup.bat at 1:30 every other day of the week. Both jobs turn off the computer when they have finished.

    8. The new batch files contain no comments. Please review my earlier posting if you'd like to know more about a particular command.

    WEEKLYBACKUP.BAT

    @echo off
    eventcreate /l application /t information /so XXXX /id 1 /d "Execution of WeeklyBackup.bat started."
    cd /d C:\
    rundll32.exe advapi32.dll,ProcessIdleTasks
    sleep 300
    taskkill /im seccopy.exe /f /t
    eventcreate /l application /t information /so XXXX /id 1 /d "Second Copy folder backups started."
    "C:\Program Files\SecCopy\seccopy.exe" "Folder Backups" /ExitWhenIdle
    eventcreate /l application /t information /so XXXX /id 1 /d "Second Copy folder backups ended."
    eventcreate /l application /t information /so XXXX /id 1 /d "True Image incremental backup started."
    "C:\Program Files\Common Files\Acronis\TrueImageHome\TrueImageHomeService.exe" /script: "C:\Documents and Settings\All Users\Application Data\Acronis\TrueImageHome\Scripts\0AC88121-1194-44CF-8541-0F91FD023190.tib.tis"
    eventcreate /l application /t information /so XXXX /id 1 /d "True Image incremental backup ended."
    eventcreate /l application /t information /so XXXX /id 1 /d "Synchronization of backup drives started."
    "C:\Program Files\SecCopy\seccopy.exe" "Backup Sync" /ExitWhenIdle
    eventcreate /l application /t information /so XXXX /id 1 /d "Synchronization of backup drives ended."
    rd /s /q E:\Backups\Images\Gen_Minus_2
    rd /s /q L:\Backups\Images\Gen_Minus_2
    rd /s /q M:\Backups\Images\Gen_Minus_2
    move E:\Backups\Images\Gen_Minus_1 E:\Backups\Images\Gen_Minus_2
    move L:\Backups\Images\Gen_Minus_1 L:\Backups\Images\Gen_Minus_2
    move M:\Backups\Images\Gen_Minus_1 M:\Backups\Images\Gen_Minus_2
    move E:\Backups\Images\Gen_0 E:\Backups\Images\Gen_Minus_1
    move L:\Backups\Images\Gen_0 L:\Backups\Images\Gen_Minus_1
    move M:\Backups\Images\Gen_0 M:\Backups\Images\Gen_Minus_1
    md E:\Backups\Images\Gen_0
    md L:\Backups\Images\Gen_0
    md M:\Backups\Images\Gen_0
    eventcreate /l application /t information /so XXXX /id 1 /d "Defrag of C: drive started."
    "C:\Program Files\RAXCO\PerfectDisk\PDCmd.exe" /SP /WAIT C:
    eventcreate /l application /t information /so XXXX /id 1 /d "Defrag of C: drive ended."
    tree > E:\Backups\Images\Gen_0\dirlist.txt
    dir /s /ogn /tc > E:\Backups\Images\Gen_0\filelist.txt
    xcopy C:\i386\edit.com E:\Backups\Images\Gen_0\
    eventcreate /l application /t information /so XXXX /id 1 /d "True Image full backup started."
    "C:\Program Files\Common Files\Acronis\TrueImageHome\TrueImageHomeService.exe" /script: "C:\Documents and Settings\All Users\Application Data\Acronis\TrueImageHome\Scripts\33B04FCE-59E5-498E-9EFA-E8CD8D3D7309.tib.tis"
    eventcreate /l application /t information /so XXXX /id 1 /d "True Image full backup ended."
    eventcreate /l application /t information /so XXXX /id 1 /d "Synchronization of backup drives started."
    "C:\Program Files\SecCopy\seccopy.exe" "Backup Sync" /ExitWhenIdle
    eventcreate /l application /t information /so XXXX /id 1 /d "Synchronization of backup drives ended."
    eventcreate /l application /t information /so XXXX /id 1 /d "Execution of WeeklyBackup.bat ended. Shutdown command will be issued."
    C:\Windows\system32\shutdown.exe -s -f -t 00


    DAILYBACKUP.BAT

    @echo off
    eventcreate /l application /t information /so XXXX /id 1 /d "Execution of DailyBackup.bat started."
    cd /d C:\
    rundll32.exe advapi32.dll,ProcessIdleTasks
    sleep 300
    taskkill /im seccopy.exe /f /t
    eventcreate /l application /t information /so XXXX /id 1 /d "Second Copy folder backups started."
    "C:\Program Files\SecCopy\seccopy.exe" "Folder Backups" /ExitWhenIdle
    eventcreate /l application /t information /so XXXX /id 1 /d "Second Copy folder backups ended."
    "C:\Program Files\Common Files\Acronis\TrueImageHome\TrueImageHomeService.exe" /script: "C:\Documents and Settings\All Users\Application Data\Acronis\TrueImageHome\Scripts\0AC88121-1194-44CF-8541-0F91FD023190.tib.tis"
    eventcreate /l application /t information /so XXXX /id 1 /d "True Image incremental backup ended."
    eventcreate /l application /t information /so XXXX /id 1 /d "Synchronization of backup drives started."
    "C:\Program Files\SecCopy\seccopy.exe" "Backup Sync" /ExitWhenIdle
    eventcreate /l application /t information /so XXXX /id 1 /d "Synchronization of backup drives ended."
    eventcreate /l application /t information /so XXXX /id 1 /d "Execution of DailyBackup.bat ended. Shutdown command will be issued."
    C:\Windows\system32\shutdown.exe -s -f -t 00
     
Thread Status:
Not open for further replies.