Project

General

Profile

Feature #6727

Ability to run a script before and after a job

Added by exobuzz over 3 years ago. Updated over 1 year ago.

Status:
In Progress
Priority:
Low
Assignee:
Category:
backupninja
Target version:
-
Start date:
02/18/2014
Due date:
% Done:

10%

QA Check:
Dev Needed

Description

Would be useful to run a script before and after a handler. That way you can do things like mount / unmount a network share, or similar. In my case I would like to mount a set of hds which requires a specific command (using mhddfs).

If I do this myself I'll attach a diff here later.

prepostrun.diff View (929 Bytes) exobuzz, 03/02/2014 01:35 AM


Related issues

Related to Backupninja - Bug #11246: rdiff-backup success generale notification New 03/16/2016

History

#1 Updated by exobuzz over 3 years ago

for now I am handling this with a 01- script to mount and a 99-script to unmount, but it could be useful to do on a per handler basis also

#2 Updated by intrigeri over 3 years ago

  • Subject changed from Ability to run a script before and after a handler to Ability to run a script before and after a job
  • Assignee set to exobuzz
  • QA Check set to Info Needed

I don't get what can't be done with shell scripts dropped into /etc/backup.d, properly named to run before/after another job. May you please clarify?

#3 Updated by exobuzz over 3 years ago

harder to manage test with ninjahelper, but most importantly, incompatible with the per handler locking. Hence they could trigger before something is finished and they are supposed to.

#4 Updated by intrigeri over 3 years ago

  • Status changed from New to Confirmed
  • Assignee deleted (exobuzz)
  • Priority changed from Normal to Low
  • QA Check deleted (Info Needed)

Ah, OK, indeed this would be great. I'm not sure what would be the best UI for this.

#5 Updated by exobuzz over 3 years ago

Attached is a patch that makes it work for me. feel free to improve or change if unsuitable.

#6 Updated by intrigeri over 3 years ago

  • Category set to backupninja
  • Status changed from Confirmed to In Progress
  • Assignee set to exobuzz
  • % Done changed from 0 to 10
  • QA Check set to Dev Needed

This looks like a nice starting point, thanks! It lacks error handling, though: what to do if either of these scripts fails?

Also, for a new feature to be mergeable, the documentation needs to be updated.

#7 Updated by exobuzz over 3 years ago

in your code you have "we have a problem! we can't grab the return code "$?". grrr." so I assume there is already a problem catching errors correctly ? Perhaps if that could be sorted we could return an error from the sub-shell ?

#8 Updated by drzraf over 1 year ago

see #11246 for another approach (we do need per-actions scripts and do need access to return code)
(as a bonus some variable get interpolated if #11258 could be fixed)
About return code, it's just a oneliner patch waiting to be merged (cf blocking #8185)

#9 Updated by intrigeri over 1 year ago

  • Related to Bug #11246: rdiff-backup success generale notification added

Also available in: Atom PDF