Răsfoiți Sursa

backup.py: add vmN/empty file if no other files to backup

Rusty Bird 6 ani în urmă
părinte
comite
6886e70aa9
2 a modificat fișierele cu 10 adăugiri și 0 ștergeri
  1. 1 0
      linux/system-config/tmpfiles-qubes.conf
  2. 9 0
      qubes/backup.py

+ 1 - 0
linux/system-config/tmpfiles-qubes.conf

@@ -1,3 +1,4 @@
 d /var/run/qubes 2770 root qubes
 f /var/run/qubes/xl-lock 0660 root qubes
+f /var/run/qubes/empty 0444 root qubes
 d /var/run/xen-hotplug 0755 root root

+ 9 - 0
qubes/backup.py

@@ -381,6 +381,15 @@ class Backup(object):
             if os.path.exists(firewall_conf):
                 vm_files.append(self.FileToBackup(firewall_conf, subdir))
 
+            if not vm_files:
+                # subdir/ is needed in the tar file, otherwise restore
+                # of a (Disp)VM without any backed up files is going
+                # to fail. Adding a zero-sized file here happens to be
+                # more straightforward than adding an empty directory.
+                empty = self.FileToBackup("/var/run/qubes/empty", subdir)
+                assert empty.size == 0
+                vm_files.append(empty)
+
             files_to_backup[vm.qid] = self.VMToBackup(vm, vm_files, subdir)
 
         # Dom0 user home