When running IF EXIST X:\ ( ECHO Exists ) ELSE ( ECHO Doesn't Exist )
, it works as expected; returns Exists when the drive is attached and returns Doesn’t Exist when the drive is not attached.
Run-script-before
I tried to recreate my problem in a minimal configuration.
Exit code 0
I expect everything to work and want to present the initial backup state before changing exit codes.
- Create new backup in webserver, no encryption, source folder with 2 jpg files, repeat backup every 10 minutes, and use advanced setting:
run-script-before C:\Duplicati\test_exit.bat
. With test_exit.bat
:
exit 0
- I manually run the backup:
Last successful backup:
Today at 12:09 PM (took 00:00:01)
Run now
Next scheduled run:
Today at 12:15 PM
Source:
374.13 KB
Backup:
377.50 KB / 1 Version
- I manually add a file to the source folder and wait for automatic backup to happen. Result 6+ minutes later:
Last successful backup:
Today at 12:15 PM (took 00:00:01)
Run now
Next scheduled run:
Today at 12:25 PM
Source:
454.73 KB
Backup:
459.50 KB / 2 Versions
Thus everything is working as expected.
Exit code 1
- I add a file to the folder and change test_exit.bat to:
exit 1
The next automatic backup results in
Last successful backup:
Today at 12:25 PM (took 00:00:00)
Run now
Next scheduled run:
Today at 12:35 PM
Source:
0 bytes
Backup:
0 bytes / 0 Versions
No error or warning signals were returned.
This is, however, not exactly as I expected since the information in my dashboard is lost regarding when the last successful backup ran, that is successful in my eyes. It looks like it ran some kind of dry backup.
Looking at the Live Log, the last message looks as expected, there is a whole list of messages before, I have copied only the last part, but I can post the rest as well:
Oct 11, 2020 12:25 PM: Aborting operation by request, requested result: Normal
Oct 11, 2020 12:15 PM: The operation Backup has completed
Oct 11, 2020 12:15 PM: Running Backup took 0:00:00:00.520
Oct 11, 2020 12:15 PM: ExecuteNonQuery: PRAGMA optimize took 0:00:00:00.000
Oct 11, 2020 12:15 PM: Starting - ExecuteNonQuery: PRAGMA optimize
Oct 11, 2020 12:15 PM: ExecuteNonQuery: DELETE FROM "RemoteOperation" WHERE "Timestamp" < 1599819300 took 0:00:00:00.000
Oct 11, 2020 12:15 PM: Starting - ExecuteNonQuery: DELETE FROM "RemoteOperation" WHERE "Timestamp" < 1599819300
Oct 11, 2020 12:15 PM: ExecuteNonQuery: DELETE FROM "LogData" WHERE "Timestamp" < 1599819300 took 0:00:00:00.000
Oct 11, 2020 12:15 PM: Starting - ExecuteNonQuery: DELETE FROM "LogData" WHERE "Timestamp" < 1599819300
Oct 11, 2020 12:15 PM: ExecuteNonQuery: UPDATE "RemoteVolume" SET "VerificationCount" = MAX(1, CASE WHEN "VerificationCount" <= 0 THEN (SELECT MAX("VerificationCount") FROM "RemoteVolume") ELSE "VerificationCount" + 1 END) WHERE "Name" = "duplicati-b8014c49423d648f2a536caf0778c0469.dblock.zip" took 0:00:00:00.009
Run-script-before-required
exit code 0
- Edit backup configuration, remove run-script-before, add run-script-before-required with
C:\Duplicati\test_exit.bat
. Change C:\Duplicati\test_exit.bat
back to exit 0
Last successful backup:
Today at 12:35 PM (took 00:00:01)
Run now
Next scheduled run:
Today at 12:45 PM
Source:
463.76 KB
Backup:
471.18 KB / 3 Versions
- The back information recovered from its ‘zero state’ as I call it where it shows 0 storage and 0 versions. Everything works as expected.
Exit 1
- Add file to destination folder and change
test_exit.bat
to exit 1
.
When the automatic backup time passes:
- The backup state remains:
Last successful backup:
Today at 12:35 PM (took 00:00:01)
Run now
Next scheduled run:
Today at 12:55 PM
Source:
463.76 KB
Backup:
471.18 KB / 3 Versions
- The Duplicati icon in the taskbar turns red with a cross (its error state).
- An error message pops up in the webserver interface:
Error while running Test_Backup
The script "C:\Duplicati\test_exit.bat" returned with exit code 1
- The stored log shows:
Oct 11, 2020 12:45 PM: Failed while executing "Backup" with id: 5
This is as expected because run-script-before-required
should always raise an error when the exit code is not 1. From my understanding you should be able to get exactly the same behaviour when using run-script-before
with exit 5
or maybe another one, but I did not test this (I can if you want me to).
What I expect
I expect run-script-before
to remain its backup state when it exits with exit 1
instead its backup information changes to 0 storage, 0 versions. This is not useful when I want to check during the weekend if my backup ran during the week when my laptop was attached to a dockingstation. For the rest it works as expected. I have not looked at the other backup codes.
Sorry for the long post. I hope I presented my process in a clear manner, but I am happy to change / add to it ![:slight_smile: :slight_smile:](https://forum.duplicati.com/images/emoji/twitter/slight_smile.png?v=9)