dom0: edit qvm-backup to use backup_do_copy, throw error when appvm is not found
This commit is contained in:
parent
65822f6033
commit
7cacc3db48
@ -1005,6 +1005,15 @@ def backup_do(base_backup_dir, files_to_backup, progress_callback = None):
|
||||
|
||||
def backup_do_copy(appvm, base_backup_dir, files_to_backup, progress_callback = None):
|
||||
|
||||
# does the vm exist?
|
||||
qvm_collection = QubesVmCollection()
|
||||
qvm_collection.lock_db_for_reading()
|
||||
qvm_collection.load()
|
||||
|
||||
vm = qvm_collection.get_vm_by_name(appvm)
|
||||
if vm is None or vm.qid not in qvm_collection:
|
||||
raise QubesException("VM {0} does not exist".format(appvm))
|
||||
|
||||
total_backup_sz = 0
|
||||
for file in files_to_backup:
|
||||
total_backup_sz += file["size"]
|
||||
@ -1026,7 +1035,7 @@ def backup_do_copy(appvm, base_backup_dir, files_to_backup, progress_callback =
|
||||
progress_callback(progress)
|
||||
dest_dir = backup_dir + '/' + file["subdir"]
|
||||
if file["subdir"] != "":
|
||||
retcode = subprocess.call (["qvm-run", "-p", appvm, "mkdir -p " + dest_dir])
|
||||
retcode = vm.run(["qvm-run", "-p", appvm, "mkdir -p " + dest_dir])
|
||||
if retcode != 0:
|
||||
raise QubesException("Cannot create directory: {0}?!".format(dest_dir))
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
from qubes.qubes import QubesVmCollection
|
||||
from qubes.qubes import QubesException
|
||||
from qubes.qubesutils import backup_prepare, backup_do
|
||||
from qubes.qubesutils import backup_prepare, backup_do_copy
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
import sys
|
||||
@ -72,7 +72,7 @@ def main():
|
||||
exit (0)
|
||||
|
||||
try:
|
||||
backup_do(base_backup_dir, files_to_backup, progress_callback=print_progress)
|
||||
backup_do_copy("storage", base_backup_dir, files_to_backup, progress_callback=print_progress)
|
||||
except QubesException as e:
|
||||
print >>sys.stderr, "ERROR: %s" % str(e)
|
||||
exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user