prune snapshots after backup fail

This commit is contained in:
usman@cyberpersons.com
2023-04-16 01:55:35 +05:00
parent 1e6a81a282
commit b5851d9076

View File

@@ -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()