btrbk: allow "0" as subvolume name

pull/30/head
Axel Burri 2015-04-07 11:52:45 +02:00
parent f08ae7d362
commit a90033c1aa
2 changed files with 14 additions and 10 deletions

View File

@ -1,3 +1,7 @@
btrbk-current
* Bugfix: allow "0" as subvolume name (closes: #10)
btrbk-0.16 btrbk-0.16
* Bugfix: correctly check retention policy for missing backups * Bugfix: correctly check retention policy for missing backups

20
btrbk
View File

@ -47,7 +47,7 @@ use Date::Calc qw(Today Delta_Days Day_of_Week);
use Getopt::Std; use Getopt::Std;
use Data::Dumper; use Data::Dumper;
our $VERSION = "0.16"; our $VERSION = "0.17-dev";
our $AUTHOR = 'Axel Burri <axel@tty0.ch>'; our $AUTHOR = 'Axel Burri <axel@tty0.ch>';
our $PROJECT_HOME = '<http://www.digint.ch/btrbk/>'; our $PROJECT_HOME = '<http://www.digint.ch/btrbk/>';
@ -169,7 +169,7 @@ sub run_cmd($;$)
sub subvol($$) sub subvol($$)
{ {
my $root = shift || die; my $root = shift || die;
my $vol = shift || die; my $vol = shift // die;
if($vol_info{$root} && $vol_info{$root}->{$vol}) { if($vol_info{$root} && $vol_info{$root}->{$vol}) {
return $vol_info{$root}->{$vol}->{node}; return $vol_info{$root}->{$vol}->{node};
} }
@ -247,7 +247,7 @@ sub check_file($$$$)
ERROR "Ambiguous file for option \"$key\" in \"$config_file\" line $.: $file"; ERROR "Ambiguous file for option \"$key\" in \"$config_file\" line $.: $file";
return undef; return undef;
} }
return $file; return 1;
} }
@ -900,7 +900,7 @@ sub get_date_tag($)
sub get_snapshot_children($$) sub get_snapshot_children($$)
{ {
my $sroot = shift || die; my $sroot = shift || die;
my $svol = shift || die; my $svol = shift // die;
my $svol_node = subvol($sroot, $svol); my $svol_node = subvol($sroot, $svol);
die("subvolume info not present: $sroot/$svol") unless($svol_node); die("subvolume info not present: $sroot/$svol") unless($svol_node);
my @ret; my @ret;
@ -955,7 +955,7 @@ sub get_receive_targets($$)
sub get_latest_common($$$;$) sub get_latest_common($$$;$)
{ {
my $sroot = shift || die; my $sroot = shift || die;
my $svol = shift || die; my $svol = shift // die;
my $droot = shift || die; my $droot = shift || die;
my $threshold_gen = shift; # skip all snapshot children with generation >= $threshold_gen my $threshold_gen = shift; # skip all snapshot children with generation >= $threshold_gen
@ -1368,7 +1368,7 @@ MAIN:
my $sroot = $config_vol->{sroot} || die; my $sroot = $config_vol->{sroot} || die;
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) foreach my $config_subvol (@{$config_vol->{SUBVOLUME}})
{ {
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} // die;
# filter subvolumes matching command line arguments # filter subvolumes matching command line arguments
if($action_run && scalar(@subvol_args)) { if($action_run && scalar(@subvol_args)) {
@ -1470,7 +1470,7 @@ MAIN:
next unless $vol_info{$sroot}; next unless $vol_info{$sroot};
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) foreach my $config_subvol (@{$config_vol->{SUBVOLUME}})
{ {
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} // die;
print "|-- $svol\n"; print "|-- $svol\n";
unless($vol_info{$sroot}->{$svol}) { unless($vol_info{$sroot}->{$svol}) {
print " !!! error: no subvolume \"$svol\" found in \"$sroot\"\n"; print " !!! error: no subvolume \"$svol\" found in \"$sroot\"\n";
@ -1518,7 +1518,7 @@ MAIN:
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) foreach my $config_subvol (@{$config_vol->{SUBVOLUME}})
{ {
next if($config_subvol->{ABORTED}); next if($config_subvol->{ABORTED});
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} // die;
my $snapdir = config_key($config_subvol, "snapshot_dir") || ""; my $snapdir = config_key($config_subvol, "snapshot_dir") || "";
my $snapshot; my $snapshot;
my $snapshot_name; my $snapshot_name;
@ -1588,7 +1588,7 @@ MAIN:
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) foreach my $config_subvol (@{$config_vol->{SUBVOLUME}})
{ {
next if($config_subvol->{ABORTED}); next if($config_subvol->{ABORTED});
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} // die;
my $snapshot = $config_subvol->{snapshot} || die; my $snapshot = $config_subvol->{snapshot} || die;
my $snapshot_name = $config_subvol->{snapshot_name} || die; my $snapshot_name = $config_subvol->{snapshot_name} || die;
@ -1715,7 +1715,7 @@ MAIN:
foreach my $config_subvol (@{$config_vol->{SUBVOLUME}}) foreach my $config_subvol (@{$config_vol->{SUBVOLUME}})
{ {
next if($config_subvol->{ABORTED}); next if($config_subvol->{ABORTED});
my $svol = $config_subvol->{svol} || die; my $svol = $config_subvol->{svol} // die;
my $snapdir = config_key($config_subvol, "snapshot_dir") || ""; my $snapdir = config_key($config_subvol, "snapshot_dir") || "";
my $target_aborted = 0; my $target_aborted = 0;
foreach my $config_target (@{$config_subvol->{TARGET}}) foreach my $config_target (@{$config_subvol->{TARGET}})