Can Acronis tasks be run from a batch file ? Trying to stagger full backups.

Discussion in 'Acronis True Image Product Line' started by Mediaman, Dec 3, 2007.

Thread Status:
Not open for further replies.
  1. Mediaman

    Mediaman Registered Member

    Joined:
    Aug 30, 2007
    Posts:
    53
    How to I set a schedule so that I for eekly full backups such that at any time I have four copies, ie

    - a one week old copy (in Directory 1)
    - a two week old (in Directory 2)
    - a three week old (in Directory 3)
    - a four week old (in Directory 4)

    I thought I had this all figured out by scheduling 4 tasks:

    - one every week (in Directory 1)
    - one every two week (in Directory 2)
    - one every three weeks (in Directory 3)
    - one every four weeks (in Directory 4)

    ....but thats all wrong as on the fourth week I will have the SAME version (each one week old) in Directory 1, 2, and 4.

    Then I thought - simple - just set up 4 tasks as follows:

    - one every four weeks (in Directory 1) - starting a fixed date
    - one every four weeks (in Directory 2) - starting one week past the fixed date
    - one every four weeks (in Directory 3) - starting two weeks past the fixed date
    - one every four weeks (in Directory 4) - starting three weeks past the fixed date

    ... but dates cannot be specified in Acronis!

    So I guess the only way to do this is with Task Scheduler....but that assumes that Acoronis has some sort of command line syntax where I can specify a specific task to run....does it have such a syntaxo_O?
     
  2. oracledba

    oracledba Registered Member

    Joined:
    Jul 17, 2006
    Posts:
    30
    Re: Can Acornis tasks be run from a batch file ? Trying to stagger full backups.

    Put me Squarely in the "ME TOO" column. I'm trying create what I consider a basic grandfather/father/son backups each week and appending/creating incrementals into that generation's full. At the next week, starting again into into a new folder/file. If acronis's scheduler would have a "starting date" then running something every three weeks, offset a week from another job would be trival. but alas it doesn't seem to have this. I haven't fully searched yet, so I guess the question is does acronis have a command line interface so we can use a decent scheduler, or does acronis have scheduler capabilities that we just aren't seeing.
     
  3. Mediaman

    Mediaman Registered Member

    Joined:
    Aug 30, 2007
    Posts:
    53
    OK figured it out. Dead simple (again!)

    1) Create 5 directories on your backup drive:

    Dir1
    Dir2
    Dir3
    Dir4
    Dir5​

    2) Create a batch file ( called rotate.bat) with the following commands
    ren dir5 dir0
    ren dir4 dir5
    ren dir3 dir4
    ren dir2 dir3
    ren dir1 dir2
    ren dir0 dir1​


    3) Schedule, in Acrnonis, a single full backup to run once per week, with the backup stored in Dir 5, with the option set to execute a commnad ( rotate.bat) after the backup is complete.

    That's it.

    Here's what happens ( unless I'm mistaken):

    After task/batch completes on the very first time, you will have:

    \Dir1 with mybackup.tib (just created)
    \Dir2 empty (not yet run)
    \Dir3 empty (not yet run)
    \Dir4 empty (not yet run)
    \Dir5 empty (not yet run)​

    After the Week 2 run, you will have:

    \Dir1 with mybackup.tib ( just created)
    \Dir2 with mybackup.tib ( created one week ago)
    \Dir3 empty (not yet run)
    \Dir4 empty (not yet run)
    \Dir5 empty (not yet run)​

    After the Week 3 run, you will have:

    \Dir1 with mybackup.tib ( just created)
    \Dir2 with mybackup.tib ( created one week ago)
    \Dir3 with mybackup.tib ( created two weeks ago)
    \Dir4 empty (not yet run)
    \Dir5 empty (not yet run)​

    After the Week 4 run, you will have:

    \Dir1 with mybackup.tib ( just created)
    \Dir2 with mybackup.tib ( created one week ago)
    \Dir3 with mybackup.tib ( created two weeks ago)
    \Dir4 with mybackup.tib ( created three weeks ago)
    \Dir5 empty (not yet run)​

    After the Week 5 run, you will have:

    \Dir1 with mybackup.tib ( just created)
    \Dir2 with mybackup.tib ( created one week ago)
    \Dir3 with mybackup.tib ( created two weeks ago)
    \Dir4 with mybackup.tib ( created three weeks ago)
    \Dir5 with mybackup.tib ( created four weeks ago)​

    ..and the above becomes the steady state.

    Mission complete.
     
    Last edited: Dec 3, 2007
  4. oracledba

    oracledba Registered Member

    Joined:
    Jul 17, 2006
    Posts:
    30
    In theory it sounds like a unique and inspired solution. GREAT JOB in coming up with that one. I'm way to tired to try this out now, but will give it due diligence this weekend. THANK YOU for the creative solution. If I'm thinking correctly it would be more logical to run rotate.bat as a "before" script in your weekly runs. This would force a NEW "dir5" location a micro second before the the "full" backup job. This "full" backup job would be defined to overwrite the original file if it exists. More importantly, because this was defined as a "before" script the location of "dir5" would remain pointing to the FULL backup for the remainder of the week (which is when the next "full" will run). This means that in addition to the "full" jobs you create a SINGLE daily run incremental which ALWAYS appends onto the "dir5" location. By scheduling in this manner you would have backups always upto yesterday, and every week your backups would flow a new folder.
     
    Last edited: Dec 4, 2007
  5. Mediaman

    Mediaman Registered Member

    Joined:
    Aug 30, 2007
    Posts:
    53
    This forum has helped me many times ; its nice to give back.


    I've tried tried both ways, and this ways works for me, but of course it can be tweaked as you see fit for your needs.

    That's how I have it set.


    I used to, but no longer, use incremental backups. So in my case, when using fulls only, running the batch 'after', when the backup is complete, works perfectly as I always have my most recent backup in Dir1, two weeks old in Dir 2 etc.

    The reason I now do only fulls and no incrementals is that :
    • I found my incrementals were getting almost a large as the fulls
    • I can now get the size down to a very manageable size given that I exclude media files (these are backed up seperately , using file backups, to multiple locations, also staggered) and have reduced the size windows system restore files
    • this appraoch frees up space to do additional and staggered full backups
    • it's just must easier to only deal with one image file at a time.
     
    Last edited: Dec 4, 2007
  6. shieber

    shieber Registered Member

    Joined:
    Oct 27, 2004
    Posts:
    3,710
    You can run scheduled tasks from the command line or the Windows Task Scheduler by calling the trueimageservice.exe (ATI10) or trueimagehomeservice.exe (ATI11) and passing as a parameter the path \filename of the script file that is created when you create a Task in ATI.

    For ATI 11, the scripts are located in C:\Documents and Settings\All Users\Application Data\Acronis\TrueImageHome\Scripts and the service is located in

    C:\Program Files\Common Files\Acronis\TrueImageHome

    For ATI 10, iirc, change "Trueimagehome" to "Trueimage" in the above and it then it works the same way.

    The scripts have long names so the trick is to edit a Task in ATI, then go to the scripts directory and see which file there has the right date-time stamp.

    So a command line would look like this.

    "C:\Program Files\Common Files\Acronis\TrueImageHome\TrueImageHomeService.exe" /script: "C:\Documents and Settings\All Users\Application Data\Acronis\TrueImageHome\Scripts\12B4EF39-C27B-490D-A954-A4D917F2F793.tib.tis"


    In the command line linstruction, note the colon after the /script switch; it is essential to include the colon.

    This all assumes that you use the standard/default directory locations for the ATI program. If not, then you'll have to make suitable adjustments to the paths.
     
  7. oracledba

    oracledba Registered Member

    Joined:
    Jul 17, 2006
    Posts:
    30
    I've finally had a chance to give due diligence to creating multi-generational backups with acronis trueimage.
    Its working perfectly for me, thought I would share how this can be done.

    Background:
    * assume you have a 2nd disk either external or on network to receive all backups
    * assume that you want several "generations" of backups so you can go back several weeks if needed. (Having several generations increases the chance a backup will be "good" should one of them get corrupted)
    * assume that you want everything automated so backups occur without your intervention.
    * for the purposes if this message "set0" is the most current backup,
    set1 will be one generation (1 week) ago,
    set2 will be two generations(2weeks ago),
    set3....

    Howto do this:
    * create a backup job "full" backup job which does:
    - a full backup
    - which writes to your device folder "/backup/pcname/set0/filename.tib where "pcname" is the name of your pc.
    - calls a pre-processing shell script (see attached).
    - Schedule this job to run weekly.

    * create another job which writes to the same filename as above but this job does NOT call a preprocessing script, Schedule this job daily.

    Thats it. All the "magic" occurs in the shell script (rotate_folders.bat).
    You will need to edit the shell script and set three variables which are unique to your environment (name of remote pc or blank if local drive, name of your target device/sharename, name of your local pc)

    The shell script will create the required folder structure if they do not exist.
    what the shell does is check if a backup exists in the set0 if so its is moved to the next generation, if a backup exists there its pushed up as well and so on for as many generations a you want to maintain (generations too old are deleted). This script is written for 3 generations but you can see the patten of what to change to add (or subtract) generations . Since both of your backup jobs always write to set0 this folder, this folder will always contain your current backup. Since the shell script is only called prior to full backups, new full backups will always begin a new generation which is flowing into an empty set0 folder. This is working for me. Hope others find it usefull as well...

    Enjoy.

    file: rotate_folders.bat
    Code:
    :: ---------------------------------------------------------------------------
    :: ---------------------------------------------------------------------------
    :: -- rotate_folders.bat
    :: -- The concept is we have two acronis jobs (full and incr) which ALWAYS backup
    :: -- to hard coded folder (set0).  
    :: -- We want to retain several generations of backups.
    :: -- One way is to simply move the *.tib files from folder set0 into set1.
    :: --
    :: -- This script maintains current + 3 generations.
    :: -- The intent our "full" job(s) will always call this script as a
    :: -- preprocessing task. This script is NOT called by incr/diff backups.
    :: -- this script will cascade all the generations up one level.
    :: -- The net effect will be folder set0 will be empty and ready to
    :: -- to receive the the full backup, any subsequent incr/diff backups
    :: -- this script assumes all backups and generations be written to the same 
    :: -- disk drive.     
    :: ---------------------------------------------------------------------------
    :: -- Define 3 three varaibles, script will create folders as needed.  
    :: -- TARGETSERVER.. name of remote pc (\\betty\) for local drive set to %blank%
    :: -- TARGETDEVICE.. your choice of sharename (xyz\) or drive leter (x:\)
    :: -- THISPC........ name of this PC
    :: ---------------------------------------------------------------------------
    set blank=" " 
    set blank=%blank:~1,1%  
    set TARGETSERVER=%blank%
    set TARGETDEVICE=e:\
    set THISPC=sidney
    :: 
    :: ---------------------------------------------------------------------------
    :: -- step 1) Create our target folders (if they don't already exist
    :: ---------------------------------------------------------------------------
    pushd %TARGETSERVER%%TARGETDEVICE% 
    if not exist .\backup\     mkdir .\backup\   
    if not exist .\backup\%THISPC%\     mkdir .\backup\%THISPC%\   
    if not exist .\backup\%THISPC%\set0 mkdir .\backup\%THISPC%\set0                 
    if not exist .\backup\%THISPC%\set1 mkdir .\backup\%THISPC%\set1 
    if not exist .\backup\%THISPC%\set2 mkdir .\backup\%THISPC%\set2 
    if not exist .\backup\%THISPC%\set3 mkdir .\backup\%THISPC%\set3
    :: 
    :: 
    :: ---------------------------------------------------------------------------
    :: step 2) coalesce empty folders
    :: This step normally is NOT needed. This step only does useful work
    :: in the rare cases where someone manually delted a backup set. 
    :: or a full backup failed prior to creating a *.tib file.
    :: If an empty generation folder exists, we backport the next higher generation
    :: into the empty the folder. We repeat this for all generations. This will
    :: "bubble up" an empty folder to end of list. The purpose of doing this
    :: bubble up is a later step will delete last generation. We don't want to
    :: delete a backup if there was an empty slot that we could have kept
    :: the backup.
    ::
    :: FYI:When source/targe folders are on same device the "move" command
    :: is very smart and fast. It does NOT copy gigs of data from one folder to the next
    :: but rather it updates the windows file system entry.  This update is
    :: lighting fast and has the effect of locating the file into the new folder.
    ::
    if NOT exist .\backup\%THISPC%\set0\*.tib if exist .\backup\%THISPC%\set1\*.tib move .\backup\%THISPC%\set1\*.tib .\backup\%THISPC%\set0\ 
    if NOT exist .\backup\%THISPC%\set1\*.tib if exist .\backup\%THISPC%\set2\*.tib move .\backup\%THISPC%\set2\*.tib .\backup\%THISPC%\set1\ 
    if NOT exist .\backup\%THISPC%\set2\*.tib if exist .\backup\%THISPC%\set3\*.tib move .\backup\%THISPC%\set3\*.tib .\backup\%THISPC%\set2\
    :: ---------------------------------------------------------------------------
    :: 
    :: 
    :: ---------------------------------------------------------------------------
    :: step 3) rotate_versions up one level which in turn makes version 0 empty
    :: 
    ::     begin by emptying (deleting) any *.tib files from the LAST folder... 
    if exist .\backup\%THISPC%\set3\*.tib del /Q /F  .\backup\%THISPC%\set3\*.tib
    :: 
    :: now rotate/migrate *.tib files from earlier foders up one level
    ::  (if a ".tib" in x move all *.tib in into x+1)
    :: When this step is done, folder set0 will be empty
    :: ---------------------------------------------------------------------------
    if exist .\backup\%THISPC%\set2\*.tib move .\backup\%THISPC%\set2\*.tib .\backup\%THISPC%\set3\ 
    if exist .\backup\%THISPC%\set1\*.tib move .\backup\%THISPC%\set1\*.tib .\backup\%THISPC%\set2\ 
    if exist .\backup\%THISPC%\set0\*.tib move .\backup\%THISPC%\set0\*.tib .\backup\%THISPC%\set1\
    :: 
    :: 
    
     
  8. Mediaman

    Mediaman Registered Member

    Joined:
    Aug 30, 2007
    Posts:
    53
    I simply use rename instead of delete and move. Much faster. My batch file, is just five lines, for five generations:

    ren dir5 dir0
    ren dir4 dir5
    ren dir3 dir4
    ren dir2 dir3
    ren dir1 dir2
    ren dir0 dir1

    So one file and one task does it for me.
     
Thread Status:
Not open for further replies.