Log each old backup as it is removed

Removing old backups can take minutes on a slow drive; logging each one with
its position (e.g. "(1/3)") shows that the backup is still progressing.
This commit is contained in:
Fuxino
2026-10-14 09:40:35 +02:00
parent 10eccd360c
commit a3ace84c8b
2 changed files with 19 additions and 2 deletions
+10 -2
View File
@@ -278,7 +278,11 @@ class Backup:
logger.info('Removing old backups...')
dirs.sort()
for i in range(n_backup - self.keep):
n_remove = n_backup - self.keep
for i in range(n_remove):
logger.info('Removing backup %s (%d/%d)...', dirs[i], i + 1, n_remove)
if self.remote_sudo:
_, _, stderr = self._ssh.exec_command(
f'sudo rm -r {shlex.quote(f"{self.output}/simple_backup/{dirs[i]}")}')
@@ -317,7 +321,11 @@ class Backup:
logger.info('Removing old backups...')
dirs.sort()
for i in range(n_backup - self.keep):
n_remove = n_backup - self.keep
for i in range(n_remove):
logger.info('Removing backup %s (%d/%d)...', dirs[i], i + 1, n_remove)
try:
rmtree(f'{self.output}/simple_backup/{dirs[i]}')
count += 1