[pve-devel] [PATCH storage] Remove the .notes file when a backup is deleted

Fabian Ebner f.ebner at proxmox.com
Wed May 11 09:37:30 CEST 2022


Commit title should include "fixes #3972"

Please note that there's also an archive_remove() function in Storage.pm
which is called when pruning. That (and I'd say archive_info() too)
should be extended to also handle the notes file.

Am 10.05.22 um 14:09 schrieb Daniel Tschlatscher:
> When a VM or Container was deleted, the .notes file was not removed,

Nit: should be "VM or Container backup"

> therefore, over time the dump folder would get polluted with notes of
> backups that no longer existed.
> As backup names contain a timestamp and as the notes cannot be reused
> because of this, I think it is safe to just delete them just like we
> do with the .log file.
>> Signed-off-by: Daniel Tschlatscher <d.tschlatscher at proxmox.com>
> ---
>  PVE/API2/Storage/Content.pm | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/PVE/API2/Storage/Content.pm b/PVE/API2/Storage/Content.pm
> index 8ff858d..3f9d77f 100644
> --- a/PVE/API2/Storage/Content.pm
> +++ b/PVE/API2/Storage/Content.pm
> @@ -457,8 +457,11 @@ __PACKAGE__->register_method ({
>  	    if ($vtype eq 'backup'
>  		&& $path =~ /(.*\/vzdump-\w+-\d+-\d{4}_\d{2}_\d{2}-\d{2}_\d{2}_\d{2})[^\/]+$/) {

It would be nice if we could simply switch to calling archive_remove()
here for non-PBS, but that might break interaction with external
plugins. But maybe we can at least re-use archive_info() to match the
path and get the log and notes file names.

>  		my $logpath = "$1.log";
> +		my $notespath = "$path.notes";
>  		# try to cleanup our backup log file too, if still existing, #318
>  		unlink($logpath) if -e $logpath;
> +		# also cleanup the .notes file if it still exists, #3972
> +		unlink($notespath) if -e $notespath;
>  	    }
>  	};
>  




More information about the pve-devel mailing list