Backup management using batch file
I downloaded a simple batch file from the Acronis web site that controls the number of backups in a set and the number of sets retained on my computer. It works well, with one exception: With each new set, the filename becomes one digit longer. Can this be controlled?

- Log in to post comments

C:\backup contains
Set1 (directory)(contains home.tib, home2.tib, home3.tib, home4.tib, home5.tib)
Set2 (directory)(contains home5.tib, home52.tib, home53.tib, home54.tib, home55.tib)
home55.tib
home552.tib
home553.tib
- Log in to post comments

Maybe attach your batch file but you will have to change the extension from bat to txt for you to be able to upload.
Or, you can post the contents of your batch file for review.
- Log in to post comments

@ECHO OFF
CLS
REM ======= Batch file for managing backup sets saved locally ============================
REM ======= Created by Acronis Customer Central ============================
REM ======= HOW TO USE ====================================================================
REM Rename the file from pre.txt to pre.bat
REM Set up one daily\weekly\monthly scheduled task selecting the option to "create incremental if possible"
REM Set this batch file as a pre-backup command
REM In the "Arguments" field of the pre-backup command specify the parameters described below diving them by one space
REM ======= PARAMETERS DESCRIPTION ========================================================
REM %1 - path to the backup folder, e.g. E:\backups
REM %2 - total amount of backups in each set (full + all incrementals), e.g. 2
REM %3 - amount of older backup sets you want to keep (set = 1 full + all its subsequent incrementals), e.g. 3
REM NOTE: total amount of backup sets will always be (%3 + 1) because there is always 1 current backup set and %3 older sets
REM ======= COUNTING HOW MANY *.tib FILES ARE IN THE PARENT FOLDER ========================
SET /a numfiles = 0
FOR %%i in (%1\*.tib) do SET /a numfiles += 1
REM ======= WHAT TO DO IF THERE ARE %2 FILES ALREADY? =====================================
IF NOT %numfiles% LSS %2 (GOTO check folders) ELSE (GOTO eof)
REM ======== CHECKING THE FOLDERS =========================================================
:check folders
REM ======= COUNTING HOW MANY SET* FOLDERS ARE ALREADY THERE ==============================
SET /a numfolders = 0
FOR /D %%i in (%1\set*) do SET /a numfolders += 1
REM ======= WHAT TO DO IF THERE ARE %3 FOLDERS ALREADY? ===================================
IF NOT %numfolders% LSS %3 (GOTO folder_rotate) ELSE (GOTO move_files)
REM ======= FOLDER ROTATION CYCLE =========================================================
:folder_rotate
REM ======== DELETING THE OLDEST FOLDER (set1) ============================================
IF EXIST %1\set1 RD /S /Q %1\set1
REM ========= ROTATING THE FOLDERS (SETTING VARIABLES) ====================================
SET /a numfolders -=1
SET /a next = 1
REM ========= ROTATION (CYCLE) ============================================================
FOR /L %%G IN (1,1,%numfolders%) DO (call :do_renames %%G %1)
GOTO move_files
REM ========= FOLDER RENAMES (CALLED BY A CYCLE) ==========================================
:do_renames
SET /a next += 1
MOVE %2\set%next% %2\set%1
GOTO eof2
REM ========= MOVE FILES FUNCTION =========================================================
:move_files
REM ========= NUMBER OF EXISTING FOLDERS +1 ===============================================
SET /a numfolders += 1
REM ========= CREATING NEW SET* FOLDER ====================================================
IF NOT EXIST %1\set%numfolders% MD %1\set%numfolders%
REM ========= MOVING BACKUP FILES FROM PARENT FOLDER TO LATEST SET* =======================
MOVE %1\*.tib %1\set%numfolders%
REM ========= DO NOTHING 1 ================================================================
:eof
SET numfiles=
SET numfolder=
REM ========== DO NOTHING 2 ===============================================================
:eof2
- Log in to post comments

I will try to help you trouble shoot this as I have time but in the meantime, if someone else can also help, that would be great.
1. What version of TrueImage are you using?
2. Add a new line to your file which is
END
3. Rerun and see if it helps.
4. You might additionally change the file extension from bat to CMD and see if it helps.
5. You will need to start over from the beginning in order to see what might work.
After the renaming function actually occurs, the C:\backup file must be empty of loose backup files so the number series of Home.tib can begin anew to create a fresh backup set. It might help to place a PAUSE statement at the end of the batch or command file so you can inspect the c:\backup folder before the backup is created each time. You should see the backup set build its content of x number of incremental and then the rename occurs and the c:\backup folder start out empty again for a new set.
This means you need to move the 3 loose files into another folder (any name) and then create a new task pointing to the c:]backup folder with the original home-.tib as its intended name,
6. Important question. Why are storing your backups on drive C? This means the C:\backup folder will be included in your next full backup unless you are excluding that folder. You need copies of your backup on some other drive if you are not already doing so.
- Log in to post comments

The build number of TI that you're using would also be helpful.
Per Grover's #5 above: If you add a PAUSE into the batch file, it will appear to "hang" when TI runs it. This is because TI doesn't support interactive commands (like PAUSE). You can't press a key, you can see the CMD window, etc. You would need to terminate cmd.exe to close it (this may cause the TI task to fail). A better solution would be to insert a "sleep" or "pause" type command to just delay things for a set amount of time while you do the check. Some people use ping for this and set the number high enough to get the delay they want. For example: ping localhost -n 40
- Log in to post comments

The problem comes from within ATI 2009. It has nothing to do with the batch file. When I tried to edit the task, I found that the name of the last backup was already in the destination box. Thus, when the batch file moves the .TIB files to SET1, SET2, etc, leaving the archive folder empty, ATI does a full backup, as it should, but it uses the name of the last backup file to make the new full backup. The next time the task runs, doing an incremental backup, it appends a "2" onto that filename, making it one character longer. That produces the directory structure I showed earlier. You should notice that the last filename in Set1 is the same as the first filename in Set2.
I set up a new task that runs every 5 minutes, and it performs the same way.
How do I find the build number?
I am backing up only selected folders, so I'm not duplicating the c:\backup folder.
I created the delay using PING, and watched the files get transferred to the subdirectories, leaving NO files in the backup directory. When the backup began, a file with a"1" appended to the name of the last incremental backup appeared, with "0" bytes file size. A minute later the file name changed, deleting the "1", and the size matched the size of previous full backups. Exactly as advertised, except for reusing the old file name. In the time it took to write this, the process repeated, creating an incremental backup with a "2" apended to the file name. How do I stop that?
- Log in to post comments


That is a really old build of TI 2009. The current build is 9,809. You may want to try the newer build and see if it still has the problem. I just ran a quick test in a VM and 9,809 didn't have the problem (9,608 did). If I remember correctly, that was a bug in the older build(s).
You may want to do an image backup of the Windows partition before doing the TI upgrade (just in case something goes wrong). Also be aware that you may need to uninstall the old build of TI before installing the new one.
- Log in to post comments



I'm glad it was successful as well. Should you want or need something with a few more options, then consider Chain2Gen inside my signature below.
- Log in to post comments

Lyle,
I finished troubleshooting this batch file and here are my results
Setting Up a Pre-Backup Command that Will Automatically Manage Backup Files Saved to a local disk
I used version 2010, build 7046 for the testing.
Unfortunately, I had similar trouble as illustrated by you in post #2 above.
Each new full backup set acquired an unwanted additional number.
Set1________________________Set2__________________Set3
test--.tib___________________test--(1).tib____________test--(2).tib
test--2.tib__________________test--(1)2.tib___________test--(2)2.tib
test--3.tib__________________test--(1)3.tib___________test--(2)3.tib
I'm glad your 2009 b9809 update worked for you as I could not get 2010 to perform to your specifications.
- Log in to post comments

Grover,
I just tested TI 2010, 6,053 (it's what I had running in a VM) and it worked correctly. Were you testing with partition images or files & folder (Data) backups? I was testing files & folders since this was the type of backup being used.
- Log in to post comments

Yes, I was also testing Files and folders. I tried it as a pre and as a post. As a bat and as a cmd.
Each time the numbering system came out the same with the extra number in parenthesis.
I don't think I saved any captures but maybe. I'll hunt but it will have to be tomorrow.
- Log in to post comments

Grover,
It's not a big deal to me.
I was just running backups manually (not using the batch file). I'd run a few backups, then create a "set#" folder and move the files. Then run some more backups. Interesting if it's different between that type of running and scheduled.
- Log in to post comments

MudCrab,
As we both are just testing to see what went wrong. Here is more info as to what I was doing.
I set up the task to run every 10 minutes. I set up the pre task with the parameters of argument to be as prescribed which was the storage folder (F:\test-cmd); the number of tib(1+6); and the number of sets(3), thus the argument was
F:\test-cmd 7 3
I thought this might be a parsing issue so i also tried the parameters in quotations and even coded the parameters inside the cmd file. All my results were identical. One thing, when I temp added a pause command, the internals is producing a couple errors about the folder names not being recognized as commands, etc.
For now, I have quit testing.
Grover
- Log in to post comments

Hi Grover and all.
On one computer I have Version 7046.
Have same problem as above.
On second computer I have Version 5055.
No problem with the naming
ALF
- Log in to post comments