From bde8d45cca08c5c0b8ec36828dae1e9706acce9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 29 Jul 2017 00:00:43 +0200 Subject: [PATCH] backup: update last backup timestamp only when backup succeed QubesOS/qubes-issues#2931 --- qubes/backup.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/qubes/backup.py b/qubes/backup.py index ab83ba03..d119095f 100644 --- a/qubes/backup.py +++ b/qubes/backup.py @@ -652,9 +652,6 @@ class Backup(object): self._done_vms_bytes += vm_info.size self._current_vm_bytes = 0 self._send_progress_update() - # Save date of last backup - if vm_info.vm: - vm_info.vm.backup_timestamp = datetime.datetime.now() yield from output_queue.put(QUEUE_FINISHED) @@ -799,9 +796,16 @@ class Backup(object): os.close(backup_stdout) else: backup_stdout.close() - if vmproc_task: - yield from vmproc_task - shutil.rmtree(self.tmpdir) + try: + if vmproc_task: + yield from vmproc_task + finally: + shutil.rmtree(self.tmpdir) + + # Save date of last backup, only when backup succeeded + for qid, vm_info in files_to_backup.items(): + if vm_info.vm: + vm_info.vm.backup_timestamp = datetime.datetime.now() self.app.save()