Hello Pat,
I understand your concern about rdiff-backup returning a non-zero exit code
even when the backup completes with warnings. In environments where
commands are chained (commandA && commandB && commandC), this can indeed be
problematic for automation.
That being said, the definition of a "successful" backup varies among
sysadmins. Since rdiff-backup is designed as a backup tool that acts as a
safety net, we took a cautious approach: if there are warnings, it means
something didn’t go as expected—perhaps it's your super critical database
failed to back up. In such cases, surfacing the issue rather than silently
ignoring it aligns with the tool's purpose.
The current implementation, however, supports both use cases. If your want
to ignore return code 2, you can easily work around this by creating a
simple Bash function, such as:
rdiff-backup-ignore-warn() {
rdiff-backup "$@"
[[ $? -eq 2 ]] && return 0
}
This way, you can ignore return code 2 when needed, while those who rely on
warnings to detect potential failures still have that safety mechanism.
I hope this better explains the current behavior.
Le mer. 12 févr. 2025, à 23 h 49, Pat Suwalski <pat@suwalski.net> a écrit :
Hello,
I've finally gotten around to an updated version of rdiff-backup where
the return codes are all weird.
I have read through the thread:
https://lists.nongnu.org/archive/html/rdiff-backup-users/2023-02/msg00034.html
I have to concur that it's very wrong for the rdiff-backup to succeed
and return non-zero.
There's an example in the thread above about doing bitwise checks on the
return code. That's all fine and dandy, but commands in a POSIX
environment must work like this:
commandA && commandB && commandC
Returning non-zero breaks this completely. In some environments (docker)
you are required to chain commands like that. Our backup scripts make
extensive use of rdiff-backup in the syntax to execute commands over a
remote SSH session using a single connection/authentication.
I would like to suggest there needs to be an option to not return >0 on
any command that actually succeeds (and it really should be the default,
too).
Thanks,
--Pat