From b2e231ebae2188851791bfd54dda22772b0b0442 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 8 May 2023 10:55:22 +0000 Subject: [PATCH] feature(backups): set job status to error if backup fails --- selfprivacy_api/backup/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/selfprivacy_api/backup/__init__.py b/selfprivacy_api/backup/__init__.py index 1992648..f3e2ba5 100644 --- a/selfprivacy_api/backup/__init__.py +++ b/selfprivacy_api/backup/__init__.py @@ -202,11 +202,15 @@ class Backups: job = add_backup_job(service) Jobs.update(job, status=JobStatus.RUNNING) - service.pre_backup() - snapshot = Backups.provider().backuper.start_backup(folders, repo_name) - Backups._store_last_snapshot(repo_name, snapshot) + try: + service.pre_backup() + snapshot = Backups.provider().backuper.start_backup(folders, repo_name) + Backups._store_last_snapshot(repo_name, snapshot) + service.post_restore() + except Exception as e: + Jobs.update(job, status=JobStatus.ERROR) + raise e - service.post_restore() Jobs.update(job, status=JobStatus.FINISHED) @staticmethod