Ability to run a command before / after backup.

Asked by Plutocrat

Hi.

It would be great to be able to run a command before / after backup as part of the expert options.

In my case, I'd like to use it to mount a drive.

I understand that I could write a script to do this.

# pseudo_script.sh
mount /drive
nice -n 19 /usr/bin/backintime --backup-job >/dev/null 2>&1
umount /drive

and then add an entry to run pseudo_script.sh in my crontab.

But then that causes problems as when I edit the preferences in Back In Time, I get an entry for pseudo_script.sh PLUS the @daily entry for backintime

Question information

Language:
English Edit question
Status:
Solved
For:
Back In Time Edit question
Assignee:
No assignee Edit question
Solved by:
Dan
Solved:
Last query:
Last reply:
Revision history for this message
Dan (danleweb) said :
#1

You can use "user-calback" script.
If you have 0.9.99.60 please check:
  man backintime

Revision history for this message
Plutocrat (plutocrat) said :
#2

OK, thanks. I was using the version which comes in the Ubuntu general repositories. I've added the testing PPA repo and now have the latest version
  sudo apt-repository-add ppa:bit-team/testing ; sudo apt-get upgrade ; sudo apt-get update

Now, looking at the man file, it isn't immediately obvious how to use user-callback. Here's the man file:

   user-callback
       During backup process the application can call a user callback at different steps. This callback is
       "$XDG_CONFIG_HOME/backintime/user-callback" (by default $XDG_CONFIG_HOME is ~/.config).
       The first argument is the progile id (1=Main Profile, ...).
       The second argument is the progile name.
       The third argument is the reason:
              1 Backup process begins.
              2 Backup process ends.
              3 A new snapshot was taken. The extra arguments are snapshot ID and snapshot path.
              4 There was an error. The second argument is the error code.
                     Error codes:

So what should I do here? I create a file ~/.config/backintime/user-callback ?
Then to run a job before backup I'd put what in it?

1 "mount /dev/drive" 1
1 "umount /dev/drive" 2

Sorry, its not so clear to me.

Revision history for this message
Best Dan (danleweb) said :
#3

write the script and if the first argument ($1) is 1 then you can mount your driver. If it is 2 then umount it.

Something like:

case $1; do
 1) mount ...;;
 2)) umount ...;;
esac

Revision history for this message
Plutocrat (plutocrat) said :
#4

Thanks Dan, that solved my question.