[pve-devel] [PATCH v3 storage] Fix #318: Delete vzdump log when deleting a backup

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Apr 8 08:30:33 CEST 2019


On 4/5/19 11:30 AM, Dominic Jaeger wrote:
> Vzdump log files were not deleted when a backup was deleted.
> Consequently, the folder continuously filled with .log files.
> Now they get deleted after the backup is removed.
> 
> Signed-off-by: Dominic Jaeger <d.jaeger at proxmox.com>
> ---
> Add regex guard
> Remove the dependency for suffix and fileparse
> Improve variable handling
> 
>  PVE/API2/Storage/Content.pm | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/PVE/API2/Storage/Content.pm b/PVE/API2/Storage/Content.pm
> index e941cb6..748f755 100644
> --- a/PVE/API2/Storage/Content.pm
> +++ b/PVE/API2/Storage/Content.pm
> @@ -307,6 +307,11 @@ __PACKAGE__->register_method ({
>  	}
>  
>  	PVE::Storage::vdisk_free ($cfg, $volid);
> +	if ($vtype eq 'backup' && $path =~
> +	    /(.*\/vzdump-\w+-\d+-\d{4}_\d{2}_\d{2}-\d{2}_\d{2}_\d{2})[^\/]+$/) {
> +	    my $logpath = "$1.log";
> +	    unlink($logpath) || die "unlink '$logpath' failed - $!\n";

If an admin has deleted a .log file we fail now as unlinks fails with a error message,
which if not rewad carefully would suggest that the deletion of the backup archive itself
failed, as besides ending log and archive share names.

Some may do this periodically for cleanup reasons, and it _just_ should not be a
reason to fail, we want to optionally cleanup.

> +	}
>  
>  	return undef;
>      }});
>




More information about the pve-devel mailing list