if bookmark creation fails use guid bases suffix based fallback name

This commit is contained in:
Christoph Klaffl 2019-02-04 18:38:09 +01:00
parent 99b439e383
commit a748b41f09
No known key found for this signature in database
GPG Key ID: FC1C525C2A47CC28
1 changed files with 17 additions and 3 deletions

20
syncoid
View File

@ -689,9 +689,23 @@ sub syncdataset {
}
if ($debug) { print "DEBUG: $bookmarkcmd\n"; }
system($bookmarkcmd) == 0 or do {
warn "CRITICAL ERROR: $bookmarkcmd failed: $?";
if ($exitcode < 2) { $exitcode = 2; }
return 0;
# fallback: assume nameing conflict and try again with guid based suffix
my $guid = $snaps{'source'}{$newsyncsnap}{'guid'};
$guid = substr($guid, 0, 6);
if (!$quiet) { print "INFO: bookmark creation failed, retrying with guid based suffix ($guid)...\n"; }
if ($sourcehost ne '') {
$bookmarkcmd = "$sshcmd $sourcehost " . escapeshellparam("$sourcesudocmd $zfscmd bookmark $sourcefsescaped\@$newsyncsnapescaped $sourcefsescaped\#$newsyncsnapescaped$guid");
} else {
$bookmarkcmd = "$sourcesudocmd $zfscmd bookmark $sourcefsescaped\@$newsyncsnapescaped $sourcefsescaped\#$newsyncsnapescaped$guid";
}
if ($debug) { print "DEBUG: $bookmarkcmd\n"; }
system($bookmarkcmd) == 0 or do {
warn "CRITICAL ERROR: $bookmarkcmd failed: $?";
if ($exitcode < 2) { $exitcode = 2; }
return 0;
}
};
}
} else {