def restore_command(parsed_options): # get and validate source/destination source = parsed_options.source destination = parsed_options.destination is_addr = is_db_address(destination) is_path = is_dbpath(destination) if is_addr and is_path: msg = ("Ambiguous destination value '%s'. Your destination matches" " both a dbpath and a db address. Use prefix 'file://'," " 'cluster://' or 'server://' to make it more specific" % destination) raise MongoctlException(msg) elif not (is_addr or is_path): raise MongoctlException( "Invalid destination value '%s'. Destination has to be" " a valid db address or dbpath." % destination) restore_options = extract_mongo_restore_options(parsed_options) if is_addr: mongo_restore_db_address(destination, source, username=parsed_options.username, password=parsed_options.password, restore_options=restore_options) else: dbpath = resolve_path(destination) mongo_restore_db_path(dbpath, source, restore_options=restore_options)
def restore_command(parsed_options): # get and validate source/destination source = parsed_options.source destination = parsed_options.destination is_addr = is_db_address(destination) is_path = is_dbpath(destination) if is_addr and is_path: msg = ("Ambiguous destination value '%s'. Your destination matches" " both a dbpath and a db address. Use prefix 'file://'," " 'cluster://' or 'server://' to make it more specific" % destination) raise MongoctlException(msg) elif not (is_addr or is_path): raise MongoctlException("Invalid destination value '%s'. Destination has to be" " a valid db address or dbpath." % destination) restore_options = extract_mongo_restore_options(parsed_options) if is_addr: mongo_restore_db_address(destination, source, username=parsed_options.username, password=parsed_options.password, restore_options=restore_options) else: dbpath = resolve_path(destination) mongo_restore_db_path(dbpath, source, restore_options=restore_options)
def dump_command(parsed_options): # get and validate dump target target = parsed_options.target use_best_secondary = parsed_options.useBestSecondary #max_repl_lag = parsed_options.maxReplLag is_addr = is_db_address(target) is_path = is_dbpath(target) if is_addr and is_path: msg = ("Ambiguous target value '%s'. Your target matches both a dbpath" " and a db address. Use prefix 'file://', 'cluster://' or" " 'server://' to make it more specific" % target) raise MongoctlException(msg) elif not (is_addr or is_path): raise MongoctlException("Invalid target value '%s'. Target has to be" " a valid db address or dbpath." % target) dump_options = extract_mongo_dump_options(parsed_options) if is_addr: mongo_dump_db_address(target, username=parsed_options.username, password=parsed_options.password, use_best_secondary=use_best_secondary, max_repl_lag=None, dump_options=dump_options) else: dbpath = resolve_path(target) mongo_dump_db_path(dbpath, dump_options=dump_options)