From b5851d90762defd9086fd63bfbde89369d0ac616 Mon Sep 17 00:00:00 2001 From: "usman@cyberpersons.com" Date: Sun, 16 Apr 2023 01:55:35 +0500 Subject: [PATCH] prune snapshots after backup fail --- plogical/Backupsv2.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plogical/Backupsv2.py b/plogical/Backupsv2.py index 7f80d82ec..4ecbaf705 100644 --- a/plogical/Backupsv2.py +++ b/plogical/Backupsv2.py @@ -225,6 +225,19 @@ team_drive = file.writelines("[" + time.strftime( "%m.%d.%Y_%H-%M-%S") + ":FAILED] " + message + "[404]" + "\n") file.close() + + ### if backup failed, we need to prune snapshots as they are not needed. + + snapshots = '' + for snapshot in self.snapshots: + snapshots = f'{snapshots} {snapshot}' + + command = f'rustic -r {self.repo} forget {snapshots} --password ""' + result = ProcessUtilities.outputExecutioner(command, self.website.externalApp, True) + + if os.path.exists(ProcessUtilities.debugPath): + logging.CyberCPLogFileWriter.writeToFile(result) + elif status == CPBackupsV2.COMPLETED: self.website.BackupLock = 0 self.website.save()