From a6740610e3f67d4619e6f46cc3ee2ba62f368687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 19 Jan 2014 04:50:56 +0100 Subject: [PATCH] backups: fix handling new format without backup header Tar will report error when 'backup-header' file wasn't found. Ignore this particular error. --- core/backup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/backup.py b/core/backup.py index 0a2025fa..5c02c5e1 100644 --- a/core/backup.py +++ b/core/backup.py @@ -963,6 +963,8 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms, else: filelist_pipe = command.stdout + expect_tar_error = False + to_extract = Queue() # If want to analyze backup header, do it now @@ -1014,6 +1016,12 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms, else: # If this isn't backup header, pass it to ExtractWorker to_extract.put(filename) + # when tar do not find expected file in archive, it exit with + # code 2. This will happen because we've requested backup-header + # file, but the archive do not contain it. Ignore this particular + # error. + if not appvm: + expect_tar_error = True # Setup worker to extract encrypted data chunks to the restore dirs # Create the process here to pass it options extracted from backup header @@ -1060,7 +1068,7 @@ def restore_vm_dirs (backup_source, restore_tmpdir, passphrase, vms_dirs, vms, passphrase, hmac_algorithm): to_extract.put(os.path.join(restore_tmpdir, filename)) - if command.wait() != 0: + if command.wait() != 0 and not expect_tar_error: raise QubesException( "ERROR: unable to read the qubes backup file {0} ({1}). " \ "Is it really a backup?".format(backup_source, command.wait()))