Pre command always succeeds
I have a vbs script that runs as a pre command. I checked "Abort the operation if the user command fails"
If the vbs script sees that the external USB backup drive is not the right drive, it does this:
WScript.Quit 1
And yet ATI always thinks the pre command succeeded, even if the Quit 1 command executed. How can the vbs script signal to ATI that the user command failed?


- Anmelden, um Kommentare verfassen zu können

Thanks Steve! That other thread "Pre-command error ignored" deals with my problem exactly. Acronis respects exit codes from .bat files, but ignores exit codes from .cmd (and apparently .vbs) scripts. Unfortunately, my script does things that are hard or impossible to do in a bat file - at least a regular bat file. Perhaps I can do it in a Powershell script. I've never used Powershell but now is my time to learn how.
- Anmelden, um Kommentare verfassen zu können

Mike, are you not able to simply put a .bat file wrapper around your .vbs script, i.e. use a .bat file to launch the vbs script? This is how I launch my Powershell scripts as is a lot simpler than having to put in the full path to the Powershell.exe in the Pre Command entry line then fiddle with passing parameters etc.
If you wish to share what you are doing in vbs with me, I can take a look to see if this is easy to do in Powershell?
- Anmelden, um Kommentare verfassen zu können

I was thinking almost the same thing as your wrapper idea. I'll run a bat file as the pre command. The bat file can check that the correct external drive is attached. If not, it will exit /b 1, causing the ATI job to abort. If the correct drive is attached, it will call a vbs script that does the rest of the work, which is deleting old backup files as needed to make room for the new backup.
Here's my current vbs script. It looks for a file with the correct name on the external drive, for example Seagate-8TB.txt. If it see it, it clears space for the new backup, which it does by assuming the new backup will be at most 1GB bigger than the most recent backup. It deletes old backups as needed until that much space is free.
Dim Arg, ExtDriveLetter, ExtDriveName
Set Arg = WScript.Arguments
Set filesys = CreateObject("Scripting.FileSystemObject")
' There is a separate Acronis backup task for each external drive, because a task needs to see the right drive ID.
' Each drive has a marker file. This program checks for the existence of that file.
' The drive name - and thus the marker file name - is passed as a parameter to this program.
' If the file is not there, this program exits with an error code of 1, which tells Acronis not to run the backup task.
' All tasks are scheduled to run each day, but only one succeeds - the one whose drive is attached.
ExtDriveLetter = Arg(0)
ExtDriveName = Arg(1)
ExtDriveFile = ExtDriveLetter & ":\Drivename\" & ExtDriveName & ".txt"
BackupFolderName = ExtDriveLetter & ":\BackupLaptop\"
If not filesys.FileExists(ExtDriveFile) Then
WScript.Quit 1
end if
' Delete oldest backup files if necessary to make space for new one.
If filesys.FolderExists(BackupFolderName) Then
Set BackupFolder = filesys.GetFolder(BackupFolderName)
Set BackupDrive = BackupFolder.Drive
if BackupFolder.files.count > 0 then
' Find latest file.
First = "T"
For each File1 in BackupFolder.files
If First = "T" Then
Set LatestFile = File1
First = "F"
Else
If File1.DateLastModified > LatestFile.DateLastModified Then
Set LatestFile = File1
End If
End If
Next
LatestFileSize = LatestFile.Size
' Delete oldest file(s) as needed to free space for new file.
Do While BackupFolder.files.count > 0 and BackupDrive.FreeSpace < LatestFileSize + 1000000000
' Find oldest file.
First = "T"
For each File1 in BackupFolder.files
If First = "T" Then
Set OldestFile = File1
First = "F"
Else
If File1.DateLastModified < OldestFile.DateLastModified Then
Set OldestFile = File1
End If
End If
Next
' Delete oldest file
OldestFile.Delete
Loop
End If
End If
Set Arg = Nothing
Set filesys = Nothing
' End of script
- Anmelden, um Kommentare verfassen zu können

Mike, thanks for the further information. Is there a particular reason why you are deleting the oldest files via your vbs script rather than using the automatic cleanup option for the ATI tasks?
My reason for asking is that if you decide to upgrade from 2018 to 2020 or 2021 versions, then this approach will run into serious problems, especially if creating disk / partition backups because Acronis have changed to using new .tibx archive files and now also use metadata to link files / chains together.
I understand that ATI automatic cleanup requires that a new Full backup is created successfully before deleting the oldest chain and there is no option to delete first then backup.
- Anmelden, um Kommentare verfassen zu können

ATI's automatic cleanup gives several options, such as delete anything older than X days, or how many versions to keep, etc. That's not what I want. I want to delete only what's needed to leave room for the new backup. If the auto cleanup had the option I want, it would be great, because I make a full backup every time. Since it doesn't offer what I want, I had to write my own script to do it.
Since I make a full backup every night, will my script approach be OK with the newer version of ATI, or will I have problems because of the metadata?
- Anmelden, um Kommentare verfassen zu können

Mike, yes your script will have a problem with ATI 2020 onwards as even full backup files are no longer independent of each other but are linked by metadata!!! Something that has been complained about by lots of users since 2020 hit the streets!
There are ways around this if only making full backups, the simplest approach being to use a pre command to rename the extension of the previous full backup file so that ATI believes it is once again creating the first backup for the task each time. Renaming the extension from .tibx to .~tibx does the trick providing you either have Acronis Active Protection turned off or else have set an exclusion for the program doing the renaming (so that AAP doesn't block the change!).
One of the MVP's (BrunoC) created a very small program that has the single purpose of doing the renaming and that could be added to the exclusions.
See forum topic: Full Backups no independent entity where this has been discussed in some depth.
- Anmelden, um Kommentare verfassen zu können

Thanks for all this useful info. But the necessity of these workarounds makes me reluctant to buy ATI 2020. Why can't ATI's cleanup offer the option to delete the oldest backup files only when space is needed? DVRs offer that option.
Speaking of which, I had to turn Acronis Active Protection of TIB files off for this exact reason. AAP stopped my program from deleting old TIB files. I tried to enter my script as an exception but it didn't work. I even opened a support ticket with Acronis but nobody could figure it out. I finally had to disable AAP's protection of TIB files.
- Anmelden, um Kommentare verfassen zu können

Mike, AAP doesn't seem to trust any script type program regardless of setting an exclusion but this does work if you have an exe that can do a delete and is set as an exclusion with AAP.
- Anmelden, um Kommentare verfassen zu können

Oh! That's great info. I can create an exe to do the deletion if that will let me turn on AAP's TIB protection (with an exclusion for my exe). Thanks!
- Anmelden, um Kommentare verfassen zu können