How to use --run-script-before-required?

I have just installed Duplicati on an Ubuntu desktop.
I am running a MySQL database on this computer and want to backup this database.

Researching this I found out, I have to:

  1. run a script to dump the MySQL database
  2. then backup the dumped data

I have found this link to with info on run-script-before-required ,however there is no practical example how to use this.

So far I found out that –run-script-before-required can be added as an Advanced Option via Settings at the Duplicati internal page.

How ever could some one provide a practical how to to do a –run-script-before-required on an Ubunti machine ?

Questions I have so far:

  • Which location would be best to save to script to ?
  • When scripting for Duplicati for Ubuntu, what script language is best used or recommended ?
  • How to connect the script with the –run-script-before-required, how should I type the path + script?

I would appreciate it, if someone could help me out with some hands-on/how to for this –run-script-before-required.

I use run-script-before-required to load shares since I use my Ubuntu server to back up LAN machines (not quite how Duplicati was intended, but I want to manage backups centrally and I also use it to back up remote client systems).

I store my scripts in /usr/local/bin/, and they are bash shell scripts.

Here’s an example of the text in the config box for one of my backups, it’s an absolute path:


The script starts with the shebang line:

#then some comments about what it does would go here

#Read a few variables

#Make sure my mount point exists
if [[ ! -d “/mnt/$host” ]] ; then
mail $fatalnotify -r “myemail” -s “FAILED MOUNT: $mount” <<< “$host does not exist in /mnt. This is a CRITICAL failure and the operation $OPERATIONNAME cannot continue.”;
logger -t “FAILED MOUNT…$host does not exist in /mnt. Exiting.”
exit 1

etc. (note there are variables in that snippet that aren’t defined here - I know it’s poor form but I don’t have time to scrub my whole script for posting on the internet, and this should be enough to get you started.)

If the script exits with status 0, the backup continues. If you send an exit other than 0, it will stop and show a fail. That’s why you see the exit 1 in the snippet above, since the mount point not existing would mean the backup can’t continue.

In your case you’d want to do a mysqldump and probably check the size of the output or something like that.

Hopefully that helps a bit!

1 Like