mirror of https://github.com/digint/btrbk
btrbk: return exit status 10 instead of 0 if one or more backup tasks aborted, and exit status 2 on parse errors
parent
e177ae1c87
commit
1905d80969
|
@ -10,6 +10,8 @@ btrbk-current
|
||||||
(experimental).
|
(experimental).
|
||||||
* Added configuration option "timestamp_format short|long".
|
* Added configuration option "timestamp_format short|long".
|
||||||
* Bugfix: correctly handle "incremental no" option.
|
* Bugfix: correctly handle "incremental no" option.
|
||||||
|
* Bugfix: return exit status 10 instead of 0 if one or more backup
|
||||||
|
tasks aborted.
|
||||||
* Hardened ssh_filter_btrbk.sh script: fine-grained access control,
|
* Hardened ssh_filter_btrbk.sh script: fine-grained access control,
|
||||||
restrict-path option, sudo option (close: #45).
|
restrict-path option, sudo option (close: #45).
|
||||||
|
|
||||||
|
|
30
btrbk
30
btrbk
|
@ -1642,7 +1642,7 @@ MAIN:
|
||||||
my ($config_cmdline, $quiet, $verbose, $preserve_backups, $resume_only);
|
my ($config_cmdline, $quiet, $verbose, $preserve_backups, $resume_only);
|
||||||
unless(GetOptions(
|
unless(GetOptions(
|
||||||
'help|h' => sub { VERSION_MESSAGE(); HELP_MESSAGE(0); exit 0; },
|
'help|h' => sub { VERSION_MESSAGE(); HELP_MESSAGE(0); exit 0; },
|
||||||
'version' => sub { VERSION_MESSAGE(); exit 0; },,
|
'version' => sub { VERSION_MESSAGE(); exit 0; },
|
||||||
'config|c=s' => \$config_cmdline,
|
'config|c=s' => \$config_cmdline,
|
||||||
'preserve|p' => \$preserve_backups,
|
'preserve|p' => \$preserve_backups,
|
||||||
'resume-only|r' => \$resume_only,
|
'resume-only|r' => \$resume_only,
|
||||||
|
@ -1655,13 +1655,13 @@ MAIN:
|
||||||
{
|
{
|
||||||
VERSION_MESSAGE();
|
VERSION_MESSAGE();
|
||||||
HELP_MESSAGE(0);
|
HELP_MESSAGE(0);
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
my $command = shift @ARGV;
|
my $command = shift @ARGV;
|
||||||
unless($command) {
|
unless($command) {
|
||||||
VERSION_MESSAGE();
|
VERSION_MESSAGE();
|
||||||
HELP_MESSAGE(0);
|
HELP_MESSAGE(0);
|
||||||
exit 0;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
# assign command line options
|
# assign command line options
|
||||||
|
@ -1723,7 +1723,7 @@ MAIN:
|
||||||
{
|
{
|
||||||
ERROR "unknown subcommand for \"config\" command: $action_config";
|
ERROR "unknown subcommand for \"config\" command: $action_config";
|
||||||
HELP_MESSAGE(0);
|
HELP_MESSAGE(0);
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
$args_expected_min = 0;
|
$args_expected_min = 0;
|
||||||
$args_expected_max = 9999;
|
$args_expected_max = 9999;
|
||||||
|
@ -1733,12 +1733,12 @@ MAIN:
|
||||||
else {
|
else {
|
||||||
ERROR "Unrecognized command: $command";
|
ERROR "Unrecognized command: $command";
|
||||||
HELP_MESSAGE(0);
|
HELP_MESSAGE(0);
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
if(($args_expected_min > scalar(@ARGV)) || ($args_expected_max < scalar(@ARGV))) {
|
if(($args_expected_min > scalar(@ARGV)) || ($args_expected_max < scalar(@ARGV))) {
|
||||||
ERROR "Incorrect number of arguments";
|
ERROR "Incorrect number of arguments";
|
||||||
HELP_MESSAGE(0);
|
HELP_MESSAGE(0);
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
# input validation
|
# input validation
|
||||||
|
@ -1759,7 +1759,7 @@ MAIN:
|
||||||
else {
|
else {
|
||||||
ERROR "Bad argument: not a subvolume" . ($args_allow_group ? "/group" : "") . " declaration: $_";
|
ERROR "Bad argument: not a subvolume" . ($args_allow_group ? "/group" : "") . " declaration: $_";
|
||||||
HELP_MESSAGE(0);
|
HELP_MESSAGE(0);
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1871,11 +1871,11 @@ MAIN:
|
||||||
my $config = parse_config(@config_src);
|
my $config = parse_config(@config_src);
|
||||||
unless($config) {
|
unless($config) {
|
||||||
ERROR "Failed to parse configuration file";
|
ERROR "Failed to parse configuration file";
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
unless(ref($config->{VOLUME}) eq "ARRAY") {
|
unless(ref($config->{VOLUME}) eq "ARRAY") {
|
||||||
ERROR "No volumes defined in configuration file";
|
ERROR "No volumes defined in configuration file";
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1950,7 +1950,7 @@ MAIN:
|
||||||
foreach(@nomatch) {
|
foreach(@nomatch) {
|
||||||
ERROR "Command line argument does not match any volume, subvolume, target or group declaration: $_";
|
ERROR "Command line argument does not match any volume, subvolume, target or group declaration: $_";
|
||||||
}
|
}
|
||||||
exit 1;
|
exit 2;
|
||||||
}
|
}
|
||||||
$config->{CMDLINE_FILTER_LIST} = [ values %match ];
|
$config->{CMDLINE_FILTER_LIST} = [ values %match ];
|
||||||
}
|
}
|
||||||
|
@ -2825,6 +2825,16 @@ MAIN:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach my $config_vol (@{$config->{VOLUME}}) {
|
||||||
|
exit 10 if($config_vol->{ABORTED} && ($config_vol->{ABORTED} ne "USER_SKIP"));
|
||||||
|
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) {
|
||||||
|
exit 10 if($config_subvol->{ABORTED} && ($config_subvol->{ABORTED} ne "USER_SKIP"));
|
||||||
|
foreach my $config_target (@{$config_subvol->{TARGET}}) {
|
||||||
|
exit 10 if($config_target->{ABORTED} && ($config_target->{ABORTED} ne "USER_SKIP"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
doc/btrbk.1
14
doc/btrbk.1
|
@ -238,9 +238,17 @@ are described in
|
||||||
.RE
|
.RE
|
||||||
.PD
|
.PD
|
||||||
.SH EXIT STATUS
|
.SH EXIT STATUS
|
||||||
.sp
|
\fBbtrbk\fR returns the following error codes:
|
||||||
\fBbtrbk\fR returns a zero exit status if it succeeds. Non-zero is
|
.IP "0" 4
|
||||||
returned in case of failure.
|
No problems occurred.
|
||||||
|
.IP "1" 4
|
||||||
|
Generic error code.
|
||||||
|
.IP "2" 4
|
||||||
|
Parse error: when parsing command-line options or configuration file.
|
||||||
|
.IP "10" 4
|
||||||
|
Backup abort: At least one backup task aborted.
|
||||||
|
.IP "255" 4
|
||||||
|
Script error.
|
||||||
.SH AVAILABILITY
|
.SH AVAILABILITY
|
||||||
Please refer to the btrbk project page
|
Please refer to the btrbk project page
|
||||||
\fBhttp://www.digint.ch/btrbk/\fR for further
|
\fBhttp://www.digint.ch/btrbk/\fR for further
|
||||||
|
|
Loading…
Reference in New Issue