public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] Remove the .notes file when a backup is deleted
@ 2022-05-10 12:09 Daniel Tschlatscher
  2022-05-11  7:37 ` Fabian Ebner
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Tschlatscher @ 2022-05-10 12:09 UTC (permalink / raw)
  To: pve-devel

When a VM or Container was deleted, the .notes file was not removed,
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@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})[^\/]+$/) {
 		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;
 	    }
 	};
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH storage] Remove the .notes file when a backup is deleted
  2022-05-10 12:09 [pve-devel] [PATCH storage] Remove the .notes file when a backup is deleted Daniel Tschlatscher
@ 2022-05-11  7:37 ` Fabian Ebner
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Ebner @ 2022-05-11  7:37 UTC (permalink / raw)
  To: pve-devel, d.tschlatscher

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@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;
>  	    }
>  	};
>  




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-11  7:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 12:09 [pve-devel] [PATCH storage] Remove the .notes file when a backup is deleted Daniel Tschlatscher
2022-05-11  7:37 ` Fabian Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal