Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Jean-Peer Lorenz proposed the following answer: Well, the result/exit code of the scripts are checked against 0. If a script fails, the whole backup will fail/not start. Post-backup scripts are being run regardless of the 'exit' status of the backup so far. Here is the corresponding code snippet: def do_hook(self, hookname): """Runs scripts optionally defined in section 'hooks' of configuration file. Currently defined are * pre-backup - before preparation of backup starts * post-backup - after completion and finishing of backup """ #LP #173490 import commands hooks = None if self.config.has_option('hooks', hookname): hooks = str(self.config.get('hooks', hookname)).split(",") if hooks is not None: self.logger.info(_("Running of hooks: %s") % hookname) for hook in hooks: result = commands.getstatusoutput(hook) if( 0 != result[0]): raise exceptions.HookedScriptError(\ "Hook %s returned error: '%s' (exit code=%s)" % (hookname, result[1], result[0])) Please feel free to file an enhancement bug report which details the desired behaviour. Thanks. -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Anton requested more information: That's nice to know! Does sbackup read the exit status of the pre-backup script, so the script could allow or block starting of the backup? Likewise, it would be good if the post-backup script could read/know the exit status of sbackup. (Ubuntu LTS - 12.04 - is providing sbackup 0.11.4) -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Jean-Peer Lorenz proposed the following answer: In sbackup 0.11.5 and newer support for Pre/Post backup script hooks was added: It is completely optional. To use it, please add following options to your configuration file: ... [hooks] pre-backup = post-backup = ... You only need to specify scripts that should run, just leave it out if not required! Please note, the script must be executable (chmod +x) and will be run with same privileges as your backup process. So, be careful! -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Anton posted a new comment: p.s., the scripts work for me. They should work for you, too, but I cannot guarantee that. Please just ask if you run into problems. -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Anton posted a new comment: /etc/network/if-up.d/sbackup #!/bin/sh # If eth0 goes up, see if we can and should make a backup now: if [ "$IFACE" = "eth0" ]; then # start backup 5 minutes in the future to allow network to come up: echo /usr/share/sbackup/retry_backup | at now + 5 min >/dev/null fi exit $? -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Status: Open => Answered Anton proposed the following answer: I have something similar (I want to check which network my laptop is on, and if a succesful backup was already made this day), so I created a script in /usr/share/sbackup (mine is called 'retry_backup' but that doesn't matter). To run it daily, I did: $ sudo ln -s /usr/share/sbackup/retry_backup /etc/cron.daily/sbackup (I also run it from /etc/pm/sleep.d/20_sbackup to try a backup when my laptop wakes up from suspend, and from /etc/network/if-up.d/sbackup to try a backup whenever eth0 comes online). After checking what needs checking, /usr/share/sbackup/retry_backup starts /usr/share/sbackup/sbackup-launch to start the actual backup. (I'll attach the three scripts separately, if possible, otherwise I'll just post them.) Alternatively, you could modify /usr/share/sbackup/sbackup-launch to insert the commands you need. -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Anton posted a new comment: /etc/pm/sleep.d/20_sbackup #!/bin/bash case "$1" in thaw|resume) # start backup 5 minutes in the future to allow network to come up: echo /usr/share/sbackup/retry_backup | at now + 5 min >/dev/null ;; *) ;; esac exit $? -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp
Re: [Nssbackup-team] [Question #234488]: lauching a task before backup
Question #234488 on sbackup changed: https://answers.launchpad.net/sbackup/+question/234488 Anton posted a new comment: /usr/share/sbackup/retry_backup: #!/bin/bash # # retry running Sbackup if previous attempt failed # used by pm to run at thaw/resume # find config file and read some variables my_dir=`dirname $0` if [ -x $my_dir/get_conf ]; then . $my_dir/get_conf else # get from default location . /usr/share/sbackup/get_conf fi # find backup schedule and check with latest succesful backup: if [ -x /usr/share/sbackup/check_backup_schedule ]; then /usr/share/sbackup/check_backup_schedule if (( $? != 1 )); then # no backup needed exit 0 fi fi # check ping to backup host # strip username, if needed: buhost=`echo $buhost | sed 's/^.*@//'` echo "Checking ping average round-trip time (rtt) to $buhost" # get average ping time in micro seconds (so it can be integer, not real): ping=`ping -c 10 $buhost | tail -1 | awk -F= '{print $2}' | awk -F/ '{print $2*1000}'` ping_max=1000 if [ $ping -gt $ping_max ]; then echo "Rtt is too slow ($ping; max $ping_max), not making backup now!" exit 0 fi for sbackup in /usr/share/sbackup/sbackup-launch /usr/bin/sbackup /usr/sbin/sbackupd; do if [ -x $sbackup ]; then echo "Launching $sbackup" $sbackup exit 0 fi done #last line -- You received this question notification because you are a member of Simple Backup Maintainers, which is an answer contact for sbackup. ___ Mailing list: https://launchpad.net/~nssbackup-team Post to : nssbackup-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~nssbackup-team More help : https://help.launchpad.net/ListHelp