backup: update last backup timestamp only when backup succeed

QubesOS/qubes-issues#2931
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-29 00:00:43 +02:00
parent 1556814f59
commit bde8d45cca
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -652,9 +652,6 @@ class Backup(object):
self._done_vms_bytes += vm_info.size self._done_vms_bytes += vm_info.size
self._current_vm_bytes = 0 self._current_vm_bytes = 0
self._send_progress_update() 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) yield from output_queue.put(QUEUE_FINISHED)
@ -799,10 +796,17 @@ class Backup(object):
os.close(backup_stdout) os.close(backup_stdout)
else: else:
backup_stdout.close() backup_stdout.close()
try:
if vmproc_task: if vmproc_task:
yield from vmproc_task yield from vmproc_task
finally:
shutil.rmtree(self.tmpdir) 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() self.app.save()