From fb8748f3e9d292ad9bf790fcf3169faef9ad8925 Mon Sep 17 00:00:00 2001 From: Olivier MEDOC Date: Wed, 14 Aug 2013 10:18:05 +0200 Subject: [PATCH] backup: implemented use of tar+gpg2 instead of only encrypting files --- dom0/qvm-core/qubesutils.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/dom0/qvm-core/qubesutils.py b/dom0/qvm-core/qubesutils.py index d84b7a8b..8aba4943 100644 --- a/dom0/qvm-core/qubesutils.py +++ b/dom0/qvm-core/qubesutils.py @@ -1042,15 +1042,32 @@ def backup_do_copy(appvm, base_backup_dir, files_to_backup, progress_callback = file["basename"] = os.path.basename(file["path"]) vm.run("mkdir -p {0}".format(dest_dir)) - if encrypt: - retcode = vm.run(command = "cat > {0}".format(dest_dir + file["basename"] + ".gpg"), passio_popen = True) - compressor = subprocess.Popen (["gpg", "-ac", "--force-mdc", "-o-", file["path"]], stdout=retcode.stdin) - else: - retcode = vm.run(command = "cat > {0}".format(dest_dir + file["basename"] + ".tar.gz"), passio_popen = True) - compressor = subprocess.Popen (["tar", "-PcOz", file["path"]], stdout=retcode.stdin) + retcode = vm.run(command = "cat > {0}".format(dest_dir + file["basename"]), passio_popen = True) + + if encrypt: + compressor = subprocess.Popen (["tar", "-PcO",'--checkpoint=10000', file["path"]],stdout=subprocess.PIPE) + encryptor = subprocess.Popen (["gpg2", "-ac", "--force-mdc", "-o-"], stdin=compressor.stdout, stdout=retcode.stdin) + encryptor.wait() + + if encryptor.returncode != 0: + raise QubesException("Failed to backup file {0} with error {1}".format(file["basename"])) + else: + compressor = subprocess.Popen (["tar", "-PcOz",'--checkpoint=10000', file["path"]],stdout=retcode.stdin) + + ''' + for checkpoint in compressor.stderr: + print "Checkpoints:",len(checkpoints) + + match = re.search('tar:.*(\d+)',checkpoints) + if match: + print bytes_backedup,total_backup_sz + progress = int(match.group(1)) * 100 / total_backup_sz + progress_callback(progress) + ''' compressor.wait() retcode.terminate() + if compressor.returncode != 0: raise QubesException("Failed to backup file {0} with error {1}".format(file["basename"]))