backups/qvm-tools: add an option to restore only selected VMs (#766)
This commit is contained in:
parent
f1bb17a3e1
commit
a4d1ede69b
@ -33,7 +33,7 @@ import sys
|
|||||||
import getpass
|
import getpass
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = "usage: %prog [options] <backup-dir>"
|
usage = "usage: %prog [options] <backup-dir> [vmname ...]"
|
||||||
parser = OptionParser (usage)
|
parser = OptionParser (usage)
|
||||||
|
|
||||||
parser.add_option ("--skip-broken", action="store_true", dest="skip_broken", default=False,
|
parser.add_option ("--skip-broken", action="store_true", dest="skip_broken", default=False,
|
||||||
@ -71,11 +71,12 @@ def main():
|
|||||||
|
|
||||||
(options, args) = parser.parse_args ()
|
(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)"
|
print >> sys.stderr, "You must specify the backup directory (e.g. /mnt/backup/qubes-2010-12-01-235959)"
|
||||||
exit (0)
|
exit (0)
|
||||||
|
|
||||||
backup_dir = args[0]
|
backup_dir = args[0]
|
||||||
|
vmlist = args[1:]
|
||||||
|
|
||||||
#if not os.path.exists (backup_dir):
|
#if not os.path.exists (backup_dir):
|
||||||
# print >> sys.stderr, "The backup directory doesn't exist!"
|
# print >> sys.stderr, "The backup directory doesn't exist!"
|
||||||
@ -123,6 +124,13 @@ def main():
|
|||||||
print >> sys.stderr, "ERROR: %s" % str(e)
|
print >> sys.stderr, "ERROR: %s" % str(e)
|
||||||
exit(1)
|
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)
|
backup_restore_print_summary(restore_info)
|
||||||
|
|
||||||
there_are_conflicting_vms = False
|
there_are_conflicting_vms = False
|
||||||
|
Loading…
Reference in New Issue
Block a user