← Back to team overview

nssbackup-team team mailing list archive

Re: [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.