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, Jun 13, 2009.

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

    The Gold Tooth Registered Member

    Joined:
    Feb 25, 2008
    Posts:
    27
    INTRODUCTION: I have previously posted to this forum the batch files I developed to automate the creation of rolling full and incremental True Image backups. This latest message will make more sense if you read my first and second postings before continuing.

    HARDWARE & SOFTWARE: Pentium D 3.2GHz, 3.25GB RAM; Windows XP Professional SP3; Acronis True Image Home 11.0 build 8,101; Second Copy 7.1.0.3; PerfectDisk 2008 build 76.

    Hard drives: 3 internal (C: 250GB, E: 750GB, L: 750GB), 1 external (M: 500GB).

    The C: drive contains the system and important data. E:, L:, and M: are backup drives.

    NOTES: I have recently enhanced the weekly batch file WEEKLYBACKUP.BAT to automatically invoke — just prior to the defragmentation of the drive being backed up — the Windows Disk Cleanup utility, which deletes unwanted clutter such as the contents of the recycle bin, temporary files, etc. (the new commands are bolded in the listing below). Performing the disk cleanup immediately before the weekly defrag and before a full disk image is taken is maximally efficient and conserves backup space, as performing one at any other time would result in the disk modifications caused by the cleanup to be stored in one of the daily incremental images.

    Another change to the weekly batch file is that I have added, for general hygiene purposes, a command (also bolded) to flush the DNS cache.

    Be aware that some preconfiguration (essentially a step to add a registry entry defining which options you wish Disk Cleanup to take) is necessary before you can perform a useful batch execution of the Disk Cleanup utility. If you simply copy the disk cleanup command from my batch file into a batch file of your own without performing this preparatory work, it will not work.

    The utility, how to use it in batch or command line mode, and how to add the registry entry are explained here, here, and here.

    For convenience I provide below both the weekly and daily batch files WEEKLYBACKUP.BAT and DAILYBACKUP.BAT. If you would like to know more about a particular command, please review my earlier postings here and here.

    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 180
    ipconfig /flushdns
    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 "Disk cleanup started."
    cleanmgr /sagerun:5
    eventcreate /l application /t information /so XXXX /id 1 /d "Disk cleanup ended."

    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 C: > E:\Backups\Images\Gen_0\C_dirlist.txt
    tree D: > E:\Backups\Images\Gen_0\D_dirlist.txt
    tree L: > E:\Backups\Images\Gen_0\L_dirlist.txt
    tree M: > E:\Backups\Images\Gen_0\M_dirlist.txt
    tree E: > E:\Backups\Images\Gen_0\E_dirlist.txt
    dir C: /s /ogn /tc > E:\Backups\Images\Gen_0\C_filelist.txt
    dir D: /s /ogn /tc > E:\Backups\Images\Gen_0\D_filelist.txt
    dir L: /s /ogn /tc > E:\Backups\Images\Gen_0\L_filelist.txt
    dir M: /s /ogn /tc > E:\Backups\Images\Gen_0\M_filelist.txt
    dir E: /s /ogn /tc > E:\Backups\Images\Gen_0\E_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
    exit

    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 180
    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."
    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
    exit
     
  2. The Gold Tooth

    The Gold Tooth Registered Member

    Joined:
    Feb 25, 2008
    Posts:
    27
    BTW, the Windows Disk Cleanup utility offers by default the option to Compress Old Files, and there's usually a long delay while it calculates how much space could be saved by selecting this option. With the size of today's hard drives there's really no reason ever to compress files, so I recommend that you permanently disable this option by following the instructions here. A real time-saver.

    TGT
     
  3. jehosophat

    jehosophat Registered Member

    Joined:
    Sep 29, 2008
    Posts:
    428
    Location:
    UK
    THE GOLD TOOTH You have done a great job creating these batch files. Thanks. Do you need the "EXIT" command after the shutdown command?

    My backup happens at 10pm and occasionally I am still using the computer when the backup runs. At the end of the backup the computer shuts down for the night.

    If I am using the computer then I dont want it to shutdown until I am ready.

    So in my shutdown command I have added a comment which appears on screen to remind me and other users that they can abort the shutdown if they want and they have 2 minutes to do so.

    To give the ability to abort the shutdown, I have simply added a icon on the desktop which runs the command "shutdown -a". The user will click on the icon and this will abort the shutdown.

    So the user can abort the shutdown initiated by the scheduled backup and carry on working.

    Here is the shutdown command that I use in my batch file:

    %SystemRoot%\System32\shutdown.exe -s -c "To abort the shutdown double click the CANCEL SHUTDOWN icon on the desktop." -t 120
     
  4. MikeV99

    MikeV99 Registered Member

    Joined:
    May 24, 2009
    Posts:
    32
    I am using pre.bat with incremental backups (path 7 3). I would like to do a consolidate task everytime the parent folder is moved into the set3 folder. How does one define and execute a consolidate task?
     
  5. shieber

    shieber Registered Member

    Joined:
    Oct 27, 2004
    Posts:
    3,710
    Could it be any simpler to use ATI? ;) Why can't Acroinis write this stuff into the program and simplfy things for users?
     
  6. blee

    blee Registered Member

    Joined:
    Dec 21, 2006
    Posts:
    26
    Re: Batch files to automate rolling full and incremental backups with Win. Task Sched

    Doesn't the use of batch files to manipulate archive files outside of TI2009 mess up TI2009's internal database which "manages" these same archive files?
     
  7. The Gold Tooth

    The Gold Tooth Registered Member

    Joined:
    Feb 25, 2008
    Posts:
    27
    Hello chaps and chapettes, The Gold Tooth here!

    To answer several follow-up posts at once:

    blee: I can't remember much about TI 2009 so I can't answer your question exactly. My approach to all versions of TI has been to use it simply as an imaging tool, ignoring any of its capabilities over and above that. So not for me Secure Zones, hidden partitions, Backup Locations, consolidations, internal databases, etc., etc. Simplicity is all.

    Batch files may be old fashioned, but they give me e-x-a-c-t-l-y what I need: three generations of backups, each one consisting of a full image and several incremental images, with copies of all generations stored on multiple hard drives. Using batch files, the Windows Disk Cleanup utility, TI, Second Copy, and PerfectDisk, I have created the perfect disk maintenance and backup solution. Perfect for me, that is, but because I'm such a nice chap I've shared my creation with the world. You may thank me with folding money.

    shieber: Thank you for your many useful contributions to this forum. "Why can't Acroinis write this stuff into the program and simplify things for users?" Hear, hear!

    MikeV99: I'm afraid I have no idea how to do a consolidation and am not strongly motivated to correct this regrettable state of affairs. Remember: complexity = bad, simplicity = good. Consolidation surely represents an additional level of complexity, and thus it is most unlikely that I'll ever do one.

    jehosophat: Perhaps my batch files don't need that "EXIT" command, but my personal standard it to terminate every batch file with an "EXIT." OCD, you say? Well, perhaps ....

    My backups run at 1:30 a.m., so I never need to be able to abort a shutdown. I'm sure other forumites will find your solution valuable, however. Thank you.

    TGT
     
  8. jehosophat

    jehosophat Registered Member

    Joined:
    Sep 29, 2008
    Posts:
    428
    Location:
    UK
    Thanks again TGT

    I have added the Exit command to my batch files now. I agree best practice and useful while testing.

    I have limited hard disk space so I have just done a batch file to create eight 10GB Bbackup files on one drive and then another eight on another.

    Automatic renaming and moving the files has been done in a simple way.
     
  9. Acronis Support

    Acronis Support Acronis Support Staff

    Joined:
    Apr 28, 2004
    Posts:
    25,885
    Hello all,

    Thank you for choosing Acronis Disk Backup Software.

    I will create a request and forward it to responsible person. Probably we will add some list of batch files for common operations to our program.

    Thank you for your understanding!

    --
    Alexander Nikolsky
     
Thread Status:
Not open for further replies.