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

Daniel Tschlatscher d.tschlatscher at proxmox.com
Tue May 10 14:09:37 CEST 2022


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 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})[^\/]+$/) {
 		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





More information about the pve-devel mailing list