backup: unify handling of template and non-template VMs
Handle them the same way - individual files, not the whole directory for templates. Also don't backup obsolete 'kernels' subdir - it isn't supported in core3.
This commit is contained in:
parent
d9cf64a41d
commit
c01f43a5d3
@ -329,9 +329,6 @@ class Backup(object):
|
|||||||
files_to_backup = {}
|
files_to_backup = {}
|
||||||
total_backup_sz = 0
|
total_backup_sz = 0
|
||||||
for vm in self.vms_for_backup:
|
for vm in self.vms_for_backup:
|
||||||
if vm.is_template():
|
|
||||||
# handle templates later
|
|
||||||
continue
|
|
||||||
if vm.qid == 0:
|
if vm.qid == 0:
|
||||||
# handle dom0 later
|
# handle dom0 later
|
||||||
continue
|
continue
|
||||||
@ -345,10 +342,7 @@ class Backup(object):
|
|||||||
if vm.private_img is not None:
|
if vm.private_img is not None:
|
||||||
vm_files += self._file_to_backup(vm.private_img, subdir)
|
vm_files += self._file_to_backup(vm.private_img, subdir)
|
||||||
|
|
||||||
# TODO: don't backup the icon
|
vm_files += self._file_to_backup(vm.icon_path, subdir)
|
||||||
if vm.is_appvm():
|
|
||||||
vm_files += self._file_to_backup(
|
|
||||||
vm.icon_path, subdir)
|
|
||||||
if vm.updateable:
|
if vm.updateable:
|
||||||
if os.path.exists(vm.dir_path + "/apps.templates"):
|
if os.path.exists(vm.dir_path + "/apps.templates"):
|
||||||
# template
|
# template
|
||||||
@ -359,9 +353,6 @@ class Backup(object):
|
|||||||
vm_files += self._file_to_backup(
|
vm_files += self._file_to_backup(
|
||||||
vm.dir_path + "/apps", subdir)
|
vm.dir_path + "/apps", subdir)
|
||||||
|
|
||||||
if os.path.exists(vm.dir_path + "/kernels"):
|
|
||||||
vm_files += self._file_to_backup(
|
|
||||||
vm.dir_path + "/kernels", subdir)
|
|
||||||
# TODO: drop after merging firewall.xml into qubes.xml
|
# TODO: drop after merging firewall.xml into qubes.xml
|
||||||
firewall_conf = os.path.join(vm.dir_path, vm.firewall_conf)
|
firewall_conf = os.path.join(vm.dir_path, vm.firewall_conf)
|
||||||
if os.path.exists(firewall_conf):
|
if os.path.exists(firewall_conf):
|
||||||
@ -387,33 +378,6 @@ class Backup(object):
|
|||||||
}
|
}
|
||||||
total_backup_sz += vm_size
|
total_backup_sz += vm_size
|
||||||
|
|
||||||
for vm in self.vms_for_backup:
|
|
||||||
if not vm.is_template():
|
|
||||||
# already handled
|
|
||||||
continue
|
|
||||||
if vm.qid == 0:
|
|
||||||
# handle dom0 later
|
|
||||||
continue
|
|
||||||
vm_sz = vm.get_disk_utilization()
|
|
||||||
if self.encrypted:
|
|
||||||
template_subdir = 'vm%d/' % vm.qid
|
|
||||||
else:
|
|
||||||
template_subdir = os.path.relpath(
|
|
||||||
vm.dir_path,
|
|
||||||
qubes.config.system_path["qubes_base_dir"]) + '/'
|
|
||||||
template_to_backup = [{"path": vm.dir_path + '/.',
|
|
||||||
"size": vm_sz,
|
|
||||||
"subdir": template_subdir}]
|
|
||||||
vm_files = template_to_backup
|
|
||||||
vm_size = reduce(lambda x, y: x + y['size'], vm_files, 0)
|
|
||||||
files_to_backup[vm.qid] = {
|
|
||||||
'vm': vm,
|
|
||||||
'files': vm_files,
|
|
||||||
'subdir': template_subdir,
|
|
||||||
'size': vm_size,
|
|
||||||
}
|
|
||||||
total_backup_sz += vm_size
|
|
||||||
|
|
||||||
# Dom0 user home
|
# Dom0 user home
|
||||||
if 0 in [vm.qid for vm in self.vms_for_backup]:
|
if 0 in [vm.qid for vm in self.vms_for_backup]:
|
||||||
local_user = grp.getgrnam('qubes').gr_mem[0]
|
local_user = grp.getgrnam('qubes').gr_mem[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user