fix #3307: make it possible to set protection for backups
A protected backup is not removed by free_image and ignored when pruning. The protection_file_path function is introduced in Storage.pm, so that it can also be used by vzdump itself and in archive_remove. For pruning, renamed backups already behaved similiar to how protected backups will, but there are a few reasons to not just use that for implementing the new feature: 1. It wouldn't protect against removal. 2. It would make it necessary to rename notes and log files too. 3. It wouldn't naturally extend to other volumes if that's needed. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
9a4c0e8471
commit
56897a9203
@ -1456,6 +1456,12 @@ sub decompressor_info {
|
||||
return $info;
|
||||
}
|
||||
|
||||
sub protection_file_path {
|
||||
my ($path) = @_;
|
||||
|
||||
return "${path}.protected";
|
||||
}
|
||||
|
||||
sub archive_info {
|
||||
my ($archive) = shift;
|
||||
my $info;
|
||||
@ -1487,6 +1493,9 @@ sub archive_info {
|
||||
sub archive_remove {
|
||||
my ($archive_path) = @_;
|
||||
|
||||
die "cannot remove protected archive '$archive_path'\n"
|
||||
if -e protection_file_path($archive_path);
|
||||
|
||||
my $dirname = dirname($archive_path);
|
||||
my $archive_info = eval { archive_info($archive_path) } // {};
|
||||
my $logfn = $archive_info->{logfilename};
|
||||
|
||||
Reference in New Issue
Block a user