btrbk: bugfix: crash if "snapshot_create onchange" is set and no snapshots are present

pull/30/head
Axel Burri 2015-05-26 18:09:36 +02:00
parent 7b9021d5c8
commit 005e5c63be
1 changed files with 10 additions and 5 deletions

15
btrbk
View File

@ -1825,12 +1825,17 @@ MAIN:
elsif($snapshot_create eq "onchange") {
# check if latest snapshot is up-to-date with source subvolume (by generation)
my $latest = get_latest_snapshot_child($sroot, $svol);
if($latest && ($latest->{gen} == $svol->{gen})) {
INFO "Snapshot creation skipped: snapshot_create=onchange, snapshot is up-to-date: $latest->{PRINT}";
$config_subvol->{SNAPSHOT_UP_TO_DATE} = $latest;
next;
if($latest) {
if($latest->{gen} == $svol->{gen}) {
INFO "Snapshot creation skipped: snapshot_create=onchange, snapshot is up-to-date: $latest->{PRINT}";
$config_subvol->{SNAPSHOT_UP_TO_DATE} = $latest;
next;
}
DEBUG "Snapshot creation enabled: snapshot_create=onchange, gen=$svol->{gen} > snapshot_gen=$latest->{gen}";
}
else {
DEBUG "Snapshot creation enabled: snapshot_create=onchange, no snapshots found";
}
DEBUG "Snapshot creation enabled: snapshot_create=onchange, gen=$svol->{gen} > snapshot_gen=$latest->{gen}";
}
elsif($snapshot_create eq "ondemand") {
# check if at least one target is present