backup/restore: improve error reporting
This commit is contained in:
parent
07cffc340c
commit
213760f263
@ -971,10 +971,12 @@ class BackupRestore(object):
|
|||||||
"ERROR: verify file {0}: {1}".format(filename, hmac_stderr))
|
"ERROR: verify file {0}: {1}".format(filename, hmac_stderr))
|
||||||
else:
|
else:
|
||||||
self.log.debug("Loading hmac for file %s", filename)
|
self.log.debug("Loading hmac for file %s", filename)
|
||||||
with open(os.path.join(self.tmpdir, hmacfile), 'r',
|
try:
|
||||||
encoding='ascii') as f_hmac:
|
with open(os.path.join(self.tmpdir, hmacfile), 'r',
|
||||||
hmac = load_hmac(f_hmac.read())
|
encoding='ascii') as f_hmac:
|
||||||
|
hmac = load_hmac(f_hmac.read())
|
||||||
|
except UnicodeDecodeError as err:
|
||||||
|
raise QubesException('Cannot load hmac file: ' + str(err))
|
||||||
if hmac and load_hmac(hmac_stdout.decode('ascii')) == hmac:
|
if hmac and load_hmac(hmac_stdout.decode('ascii')) == hmac:
|
||||||
os.unlink(os.path.join(self.tmpdir, hmacfile))
|
os.unlink(os.path.join(self.tmpdir, hmacfile))
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
@ -1753,14 +1755,13 @@ class BackupRestore(object):
|
|||||||
try:
|
try:
|
||||||
self._restore_vm_data(vms_dirs=vms_dirs, vms_size=vms_size,
|
self._restore_vm_data(vms_dirs=vms_dirs, vms_size=vms_size,
|
||||||
handlers=handlers)
|
handlers=handlers)
|
||||||
except QubesException:
|
except QubesException as err:
|
||||||
if self.options.verify_only:
|
if self.options.verify_only:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
self.log.error('Error extracting data: ' + str(err))
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
"Some errors occurred during data extraction, "
|
"Continuing anyway to restore at least some VMs")
|
||||||
"continuing anyway to restore at least some "
|
|
||||||
"VMs")
|
|
||||||
|
|
||||||
if self.options.verify_only:
|
if self.options.verify_only:
|
||||||
shutil.rmtree(self.tmpdir)
|
shutil.rmtree(self.tmpdir)
|
||||||
|
Loading…
Reference in New Issue
Block a user