:: lineb of two line backup :: both lines are manual fulls. @echo off :: !_USER_SPECIFIED_PARAMS_FOR_Acronis.bat :: :: ******************************************************************************** :: Users of this application ARE expected to read and edit this file :: Do not delete any code simply change values on the right hand side of :: equal sign to achieve your Acronis generation goals. :: ******************************************************************************** :: :: :: :: Purpose: The intent is this bat file is to empower the user a means to control :: when Acronis creates a new "full" backup versus when to make an "incr" :: This application also empowers the user with how many "generations" of :: backup chains to retain. :: :: :: This file is the ONLY file a user is expected to EDIT to control :: Acronis date and chain processing (generations). :: SETTING PARAMS IN THIS FILE CONTROL THE BEHAVIOR FOR THE REST OF THE SYSTEM. :: Do not delete any lines of code, confine your edits to the right hand side :: of each variables equal sign. :: :: Background: Acronis TI does a superior job in creating and maintaining a current backup. :: But Acronis TI does not easily lend itself to maintaining backup generations. :: One way to get Acronis TI to do backup generations is to use this application. :: A user is expected to define an Acronis TI backup which calls :: "Acronis_PreProcessing_task.bat" as a PREprocessing task. :: The typical Acronis backup task would be a daily INCR. :: The backup task must be defined to NOT create new fulls (ever) nor :: should this backup task ever do a to "consolidate". The main reason why :: is both actions cause one to "lose" history. Maintaining history :: is this scripts responsibility starting new chains is also this :: scripts responsibility. :: The users backup job MUST write to a target folder named "set0" :: this folder can be any number of sub-directories deep. :: The typical filename of the Acronis backup job will be something :: like this (note the trailing dash): :: \\server\device\xxx\yyy\zzz\set0\mybackup-.tib :: :: Configuration: User MUST define the three mandatory variables listed below. :: User Should define one or more optional "trigger" conditions :: for when a new full backup should be taken (which also means :: the prior backup chain is rotated into the history/generation folders. :: The following "automatic" trigger conditions are available: :: 1) total number of "tib" files in the full/incr chain. :: 2) today is the xx of the month (such as the 15th of the month) :: 3) today is a specific day of the week (such as sunday) :: 4) today is a specific day of every OTHER week (such as every other sunday) :: 5) today is a specific occurrence of the day in the month (3rd sunday) :: 6) SUM of the INCR files exceeds users max (assumes full contained in 1 file) :: Regardless of one using (or not) any of the automatic trigger conditions :: one can MANUALLY cause a new chain to occur by creating a file :: called "trigger.txt" in the "set0" folder. The contents of the file :: does not matter its mere existence is enough cause the current :: backup set to be moved into history and the next Acronis backup :: then becoming a full. :: :: This file and all the files of the application are expected to reside :: in the same folder. Treat this folder as source code and place it :: on your 'C:' drive so it is backed up whenever you do a c:\ drive backup. :: :: Acronis: The reason why this system works is an Acronis incr backup processing :: first looks at the target folder if it does NOT see an existing chain :: it creates both a new full backup .tib file and new backup set in the recovery catalog. :: subsequent incr backups are added to this chain and recovery catalog. :: This continues until such time as this script empties the set0 folder. :: the cycle then repeats with a new full and new recovery catalog chain. :: The above will "orphan" prior catalog entries - these will remain in the :: Acronis recovery catalog. Since I never use the catalog it does not bother me. :: :: At anytime you may change the params of this file. The next run of Acronis will use them. :: This application will create any backup generation folders needed. :: Most users will have one and only copy of this application. :: There are logical reasons why you would have multiple copies. :: Such as if you have two Hard disks (system and data) and you desire :: Different backup schedules and generation history for each. :: In this circumstance you would have two complete copies of this application in different folders. :: You would then edit the "params" file of each folder setting the params desired. :: You would have 2 Acronis backup jobs one for each application folder. :: :: Revisions :: v1.0 10/22/2009 Initial version :: v1.5 10/23/2009 minor bug fixes and added error dialog boxes :: v1.9.1 10/24/2009 preparing to release as v2.0 :: v1.9.2 10/26/2009 preparing to release as v2.0 :: v1.9.3 10/29/2009 preparing to release as v2.0 :: v1.9.4 10/29/2009 preparing to release as v2.0 :: v1.9.5 10/30/2009 preparing to release as v2.0 :: v1.9.6 11/06/2009 preparing to release as v2.0 :: v1.9.8 11/08/2009 bug fix/preparing to release as v2.0 :: v2.0 11/10/2009 released as v2.0 :: v2.2 11/30/2009 added variables PRE_FULL_BACKUP_CMD[1-5] to run user commands when a new chain(full) is about to occur. :: v2.3 2010_01_04 comments added for new acronis job param "always" :: echo Typical runtime of this script is 20 seconds or less. set Scriptdir=%~dp0 :: :: :: --------------------------------------------------------------------------- :: Step 1 :: You MUST define the following three variables :: TARGET_UNC_N_DEVICE.......... This can be UNC or drive letter do NOT use a trailing slash :: example(s) \\Maximus\E (1TB device) or x: :: TARGET_GENERATIONS_FOLDER.... The directory tree on your device to receive all generations :: the trailing slash is required. :: example(s) \backup\sidney\ :: MAX_BACKUP_GENERATIONS....... 0 means no history other than the current set (set0) :: 1 means 1 generation beyond the current "set0" backup :: 3 is a typical value but any positive integer will work. :: --------------------------------------------------------------------------- :: MANDATORY VARIABLES :: User must change these next 3 variable and supply their own pertinent information. set TARGET_UNC_N_DEVICE=G: set TARGET_GENERATIONS_FOLDER=\FullBackups\ set MAX_BACKUP_GENERATIONS=3 :: :: :: :: To automate your full backups you MUST set at least ONE of the :: following (optional) trigger conditions. :: If you choose to NOT set any of the following variables then you will only :: get a new generation (and new full backup) if you MANUALLY create the trigger file. :: (The trigger file can be manually created by running script: "!_FORCE_NEW_CHAIN.bat" :: : :: ---Examples begin here---------------------------------------------------- :: option 1 set a trigger based on total number of .tib files in folder :: 0 means unlimited incr :: 1 means a new full every time (1 Full + 0 incr = 1) :: 2 means a new full after 1 incr is done (1 Full + 1 incr = 2) :: 3 means a new full after 2 incr is done (1 Full + 2 incr = 3) :: The thought behind this control is the exposure risk of an incr chain is a :: function of the chain length. Hence start a new chain when the length :: of the chain exceeds some threshold. (or set 0 for manual control) :: TRGR_ON_MAX_TIB_CNT=1 0=unlimited N=max_number of ".tib" files in chain :: --User must set this next variable if the preceding option 1 is applicable-------------- set TRGR_ON_MAX_TIB_CNT=1 :: --------------------------------------------------------------------------- :: :: :: :: :: --------------------------------------------------------------------------- :: Option 2 set a trigger based on today being a specific date number of month :: such as start a new chain on today being that date. :: Five of these are provided for those that want to do this multiple times such as on the 1st and 15th. :: TRGR_ON_DD1=[0-31] 0=ignore 1-31 is calendar day number :: TRGR_ON_DD2=[0-31] 0=ignore 1-31 is calendar day number :: TRGR_ON_DD3=[0-31] 0=ignore 1-31 is calendar day number :: TRGR_ON_DD4=[0-31] 0=ignore 1-31 is calendar day number :: TRGR_ON_DD5=[0-31] 0=ignore 1-31 is calendar day number :: for example to get a new full backup on the 1st and the 15th :: set one of these to 1 and another to 15 :: ----User must set this next variable(s) if the preceding option 2 is applicable--- set TRGR_ON_DD1=0 set TRGR_ON_DD2=0 set TRGR_ON_DD3=0 set TRGR_ON_DD4=0 set TRGR_ON_DD5=0 :: --------------------------------------------------------------------------- :: :: :: :: :: ---Examples begin here----------------------------------------------------- :: Option 3 set a trigger based on today being a specific day of week :: such as start a new chain on every monday (useful for weekly generations) :: This control is very useful when the time window to do a full backup only exists on certain days such as Sunday. :: TRGR_ON_DAY1=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every xxx :: TRGR_ON_DAY2=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every xxx :: TRGR_ON_DAY3=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every xxx :: TRGR_ON_DAY4=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every xxx :: TRGR_ON_DAY5=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every xxx :: for example to get a new full backup on the Thursday and sunday :: set one of these to Thu and another to Sun :: --User must set this next variable(s) if the preceding option 3 is applicable--------- set TRGR_ON_DAY1=Mon set TRGR_ON_DAY2=~ set TRGR_ON_DAY3=~ set TRGR_ON_DAY4=~ set TRGR_ON_DAY5=~ :: --------------------------------------------------------------------------- :: :: :: :: :: --------------------------------------------------------------------------- :: Option 4 set a trigger based on today being a specific day of every OTHER week :: such as start a new chain on every OTHER sunday (useful for by-weekly generations) :: TRGR_ON_EVO_DAY1=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every other xxx :: TRGR_ON_EVO_DAY2=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every other xxx :: TRGR_ON_EVO_DAY3=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every other xxx :: TRGR_ON_EVO_DAY4=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every other xxx :: TRGR_ON_EVO_DAY5=[~|Mon|Tue|Wed|Thu|Fri|Sat|Sun] ~=ignore xxx=every other xxx :: for example to get a new full backup on every other Thursday and sunday :: set one of these to Thu and another to Sun :: --User must set this next variable(s) if the preceding option 4 is applicable---------------- set TRGR_ON_EVO_DAY1=~ set TRGR_ON_EVO_DAY2=~ set TRGR_ON_EVO_DAY3=~ set TRGR_ON_EVO_DAY4=~ set TRGR_ON_EVO_DAY5=~ :: :: --Examples begin here---------------------------------------------------------------- :: Option 4a :: The definition of EVO (which week is considered the "other" week) :: is set by the current week being an even or odd number week from the :: beginning of the year. :: Set USE_EVO_VAL to 0 to get the EVO processing on dates of even weeks :: or set this value to 1 for EVO processing to occur on odd weeks. :: -User must set this next variable if the preceding option 4a is applicable-- set USE_EVO_VAL=1 :: --------------------------------------------------------------------------- :: :: :: :: :: ---Examples begin here-------------------------------------------------------- :: Option 5 set a trigger based on today being a specific occurrence of day in a month :: such as start a new chain on 2nd saturday of the month "2nd_Sat" (no quotes) :: (Typical usage is similar to monthly generations but user needs to have the :: full backup occur on a specific day such as on a sunday. :: TRGR_ON_OCRDAY1=[~|{1st|2nd|3rd|4th|5th}_{Mon|Tue|Wed|Thu|Fri|Sat|Sun}] :: TRGR_ON_OCRDAY2=[~|{1st|2nd|3rd|4th|5th}_{Mon|Tue|Wed|Thu|Fri|Sat|Sun}] :: TRGR_ON_OCRDAY3=[~|{1st|2nd|3rd|4th|5th}_{Mon|Tue|Wed|Thu|Fri|Sat|Sun}] :: TRGR_ON_OCRDAY4=[~|{1st|2nd|3rd|4th|5th}_{Mon|Tue|Wed|Thu|Fri|Sat|Sun}] :: TRGR_ON_OCRDAY5=[~|{1st|2nd|3rd|4th|5th}_{Mon|Tue|Wed|Thu|Fri|Sat|Sun}] :: ---User must set this next variable if the preceding option 5 is applicable------- set TRGR_ON_OCRDAY1=~ set TRGR_ON_OCRDAY2=~ set TRGR_ON_OCRDAY3=~ set TRGR_ON_OCRDAY4=~ set TRGR_ON_OCRDAY5=~ :: --------------------------------------------------------------------------- :: :: :: :: :: ----Examples begin here---------------------------------------------------------- :: Option 6 set a trigger based the SUM of the INCR file sizes exceeding a users threshold. :: The thought behind this control is regardless of how many gig the full backup :: might be, it is the total MB of the incrs which represent the exposure risk. :: Hence start a new chain when the "weight" in incrs exceed a MB threshold. :: We will do this regardless of how many incr files it takes to exceed the threshold. :: TRGR_ON_TOTAL_SUM_INCR_MB=[0-N] 0=unlimited N=max_sumsize in MB :: ----User must set this next variable if the preceding option 6 is applicable-------------- set TRGR_ON_TOTAL_SUM_INCR_MB=0 :: --------------------------------------------------------------------------- :: :: :: if you desire a specific program/batchfile/command issued PRIOR to a full backup occuring :: then enter the call for that command into any of these five varaibles. :: Possible examples of desirable commands are to do a DEFRAG of your C: PRIOR to a full backup. :: For example in Windows xp to defrag you would set: :: set pre_full_backup_cmd1=defrag c: :: These variables are used by "Acronis_PreProcessing_task.bat" and the processing for them :: is restricted to occur only when a new chain (full) is about to occur. :: If you need something done prior to EVERY backup then do NOT use :: these variables. Instead use custom script "my_acronis_pretask.bat" and insert your desired :: code into this script. Your actual acronis backup of course would need :: its pretask to be a call to "my_acronis_pretask.bat" not "Acronis_PreProcessing_task.bat" :: FYI: The default chain2gen behavior is to only run these commands when retiring an existing chain. :: if you want these pre_full_backup_commands run for prior to any full backup including the :: the initial backup then you must specify the param "ALWAYS" (NO QUOTES) in the acronis :: job definition GUI panel. :: Warning- while the intent of these variables was to call an actual .exe one can call a ".bat" script :: HOWEVER please use a "start" verb as in set PRE_FULL_BACKUP_CMD1=start c:\my_script.bat :: FURTHERMORE the .bat file call MUST end with an "EXIT" command. Failure to do so may (will) :: cause the acronis pretask to "hang" (never finish). set PRE_FULL_BACKUP_CMD1=~ set PRE_FULL_BACKUP_CMD2=~ set PRE_FULL_BACKUP_CMD3=~ set PRE_FULL_BACKUP_CMD4=~ set PRE_FULL_BACKUP_CMD5=~ :: :: :: USER EDITS ARE FINISHED. :: :: :: --------------------------------------------------------------------------- :: --------------------------------------------------------------------------- :: --------------------------------------------------------------------------- :: :: :: :: :: The following code is rather redundant to normal processing. :: its here strictly as a courtesy for when a user tries to run :: this script directly. The users data entry (above) :: will be undergo a syntax/validation and the user will receive a popup dialog :: box with the validation result. call "%Scriptdir%Validate_PARAMS.bat" if NOT "%ERRORLEVEL%"=="0" ( echo "could not call or successfully run %Scriptdir%Validate_PARAMS.bat" EXIT /B 99 ) :: :: If user double clicks this file then "%1" will be blank which means :: the user is running this interactively its reasonable to assume the interactive :: run is either for testing and/or to get info to setup an Acronis backup job. :: To assist their efforts lets place the location of the backup set0 into :: their windows clipboard. set v_set0="%TARGET_UNC_N_DEVICE%%TARGET_GENERATIONS_FOLDER%set0\" set msg1=Validation of params was successful#br#When you define your Acronis backup task it WILL need to EXACTLY match the folder name you have just defined. set msg2=#br##br#FYI: This folder DOES exist if NOT exist %v_set0% set msg2=#br##br#FYI: This folder does NOT exist#br#To create these backup generation folder(s) please run Acronis_PreProcessing_task.bat IF (%1)==() ( call "%Scriptdir%copy_p1_into_clipboard.vbs" %v_set0% "%msg1%%msg2%" ) :: :: :: :: an exit /b 0 is required as the last line of this shell script... exit /b 0