backups/qvm-tools: add an option to restore only selected VMs (#766)

This commit is contained in:
Marek Marczykowski-Górecki 2014-01-19 04:52:13 +01:00
parent f1bb17a3e1
commit a4d1ede69b

View File

@ -33,7 +33,7 @@ import sys
import getpass
def main():
usage = "usage: %prog [options] <backup-dir>"
usage = "usage: %prog [options] <backup-dir> [vmname ...]"
parser = OptionParser (usage)
parser.add_option ("--skip-broken", action="store_true", dest="skip_broken", default=False,
@ -71,11 +71,12 @@ def main():
(options, args) = parser.parse_args ()
if (len (args) != 1):
if (len (args) < 1):
print >> sys.stderr, "You must specify the backup directory (e.g. /mnt/backup/qubes-2010-12-01-235959)"
exit (0)
backup_dir = args[0]
vmlist = args[1:]
#if not os.path.exists (backup_dir):
# print >> sys.stderr, "The backup directory doesn't exist!"
@ -123,6 +124,13 @@ def main():
print >> sys.stderr, "ERROR: %s" % str(e)
exit(1)
if len(vmlist) > 0:
for vm in restore_info.keys():
if vm.startswith('$'):
continue
if not vm in vmlist:
restore_info.pop(vm)
backup_restore_print_summary(restore_info)
there_are_conflicting_vms = False