Hi.
why is that postfilebackup ignores any exit codes? I have a postfilebackup helper that could fail and I cant detect it?
@uroni Could we have a setting for this somehow? Or make it behaving like prefilebackup?
Thanks in advance ![]()
Hi.
why is that postfilebackup ignores any exit codes? I have a postfilebackup helper that could fail and I cant detect it?
@uroni Could we have a setting for this somehow? Or make it behaving like prefilebackup?
Thanks in advance ![]()
Hi, I looked at the client code. postfilebackup is started as a detached process after the client has already confirmed the end of the transfer to the server (on Linux a double fork, on Windows CreateProcess without waiting), so neither its exit code nor its output is collected anywhere. prefilebackup is run differently: the client waits for it, logs its output and fails the backup on a non-zero exit code.
Making postfilebackup work the same way needs a small protocol change: the client would wait for the script and send its result to the server, and the server would mark the backup as completed with issues and put the output in the backup log. It probably needs a timeout or an opt-in setting, since some people start long-running jobs from that script. @uroni, if you’re fine with that approach I can make a PR.
Until then the script has to report its own failures (mail, monitoring and so on). Also, the manual is outdated here: postfilebackup gets the file backup group and client subname as parameters, and there is a postfilebackup_failed script that runs when a backup fails.
@KluthR Could you outline a specific use case for this?
@LJ_LongWing Perhaps add a new script postfilebackup_checked or similar that has its return value checked and its output put into the backup log via VSSLOG command.
I have some tasks which run after a backup. But as I write this - these tasks have nothing to do with the backup itself, which could justify a failed backup in case these fail. Maybe that was your initial intention to not check anything inside post*backup scripts. So, since I have no mail service, UrBackup would mail me - so was my thought.
So, you idea to have a _checked version is great, maybe with an option to not mark the backup as failed but notify the user about the failed post-script? Not sure if UrBackup should handle this.
The main reason for the current state is that a backup can finish successfully with the client being offline at this stage (so it fails to run the postfilebackup as well in that case).
Thanks, a separate postfilebackup_checked script sounds good. It also avoids changing how the existing script behaves for anyone who starts long-running jobs from it.
My plan: the client runs postfilebackup_checked (or postfilebackup_checked.bat on Windows) at the end of the file backup and waits for it. Each line of output goes into the backup log via VSSLOG. If the client goes offline before the script finishes, the backup still finishes and the log says the script didn’t complete.
For a non-zero exit code, I’d log it as an error but keep the backup successful by default, as KluthR suggested, because the backed-up data is fine. An option could fail the backup instead. Would you prefer it that way, or should it always fail?
Idk, then the only difference would be what goes into the log? Then perhaps just do it for the normal postfilebackup. I guess you could put output of postfilebackup into log (as error if it fails) and have a postfilebackup_checked that fails with non-zero exit code.
Sounds good. So postfilebackup_checked fails the backup on a non-zero exit code, and also if the client goes offline before the script finishes.
One question about the normal postfilebackup: today the client starts it and doesn’t wait for it. To put its output in the log, the server has to wait until it finishes, and that would hold up backups for people who start long jobs from it. Should it wait, or should I only log the output if the script finishes within a few minutes, and log nothing otherwise?