From: Joar Wandborg Date: Sun, 7 Aug 2011 03:00:46 +0000 (+0200) Subject: Feature #298 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=224813d28cc60aa7ec1ead34ea028713a2d61c74;p=mediagoblin.git Feature #298 * Added some minor things to gmg_commands.import_export --- diff --git a/mediagoblin/gmg_commands/import_export.py b/mediagoblin/gmg_commands/import_export.py index c0ac444b..aa3fe1a1 100644 --- a/mediagoblin/gmg_commands/import_export.py +++ b/mediagoblin/gmg_commands/import_export.py @@ -38,6 +38,12 @@ def import_export_parse_setup(subparser): subparser.add_argument( '--mongodump_path', default='mongodump', help='mongodump binary') + subparser.add_argument( + '--mongorestore_path', default='mongorestore', + help='mongorestore binary') + subparser.add_argument( + '--extract_path', default='/tmp/mediagoblin-import', + help='the directory to which the tarball should be extracted temporarily') def _export_database(db, args): print "\n== Exporting database ==\n" @@ -55,13 +61,22 @@ def _export_database(db, args): print "\n== Database exported ==\n" def _import_database(db, args): - pass + command = '{mongorestore_path} -d {database} -o {mongodump_cache}'.format( + mongorestore_path=args.mongorestore_path, + database=db.name, + mongodump_cache=args.mongodump_cache) def env_import(args): config, validation_result = read_mediagoblin_config(args.conf_file) connection, db = setup_connection_and_db_from_config( config['mediagoblin'], use_pymongo=True) + tf = tarfile.open( + args.tar_file, + mode='r|gz') + + tf.extractall(args.extract_path) + def env_export(args): config, validation_result = read_mediagoblin_config(args.conf_file) connection, db = setup_connection_and_db_from_config(