From 2b91178e9494efa0b5e8ddc99602f673be5a36bd Mon Sep 17 00:00:00 2001 From: Fuxino Date: Thu, 8 Oct 2026 17:38:34 +0200 Subject: [PATCH] Don't remove old backups if rsync fails If rsync returns an error, the new backup may be incomplete. Keep the old backups in that case, except for return code 24 (vanished source files), which is expected when backing up a live system. --- simple_backup/simple_backup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index 77df8dd..3d9420e 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -587,7 +587,11 @@ class Backup: logger.error(output) if self.keep != -1 and not self._remove_before: - self.remove_old_backups() + # Don't delete old backups if the new one may be incomplete + if returncode in [0, 24]: + self.remove_old_backups() + else: + logger.warning('Backup not completed successfully. Old backups will not be removed') os.remove(self._inputs_path) os.remove(self._exclude_path)