How to run a script only before a backup?

I am running Duplicati on Ubuntu 22.04. I wrote a simple MySQL backup script and want it to run before each backup. The script saves the backup (mysqldump) in /home/user/backups/. I then ran a backup last night. It appears to have worked as I did a restore this morning, and the restored mysql backup file was correct. However, it seems every time I run a restore, my script is run and more backups are created. I now have 8 copies of the mysql backup file in my backups directory - 1 from last night and 7 from today when I went through the restore process. How do I set up the script to only run when I am doing a backup? I am using run-script-before-required.

Do I need to check the value of DUPLICATI__OPERATIONNAME, and just run the script when the value is “Backup”? Do I need to check any of the other Duplicati env variables to achieve running the script only for a backup?

Thanks!

Never mind. Checking the DUPLICATI__OPERATIONNAME env variable fixed the problem. If I could see a way to delete this post, I would!

We now return you to your regularly scheduled programming…

Forum moderators can delete posts on request (just PM me or one of the others).
But I generally think we should keep the original posts, so others with the same question can find the answer.

And awesome that you found the solution!