summaryrefslogtreecommitdiffstats
path: root/result_collection_api/update/restore.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-06-07 14:34:14 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-06-07 14:52:09 +0800
commit3906e03eb6b710515b35af6aa73eba6ea6faf5b6 (patch)
tree6a2a443061d7d89952503d3eca0ef49a753c6bff /result_collection_api/update/restore.py
parent67c7bee7345bbc7f4cf7b046f93cb1c049481099 (diff)
add mongodb backup and restore scripts in testAPI
add directory update add files backup.py restore.py utils.py JIRA: FUNCTEST-297 Change-Id: I6e8b6c4b87b6081e67bc3e1a7605c83d0232e3ca Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'result_collection_api/update/restore.py')
-rw-r--r--result_collection_api/update/restore.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/result_collection_api/update/restore.py b/result_collection_api/update/restore.py
new file mode 100644
index 0000000..a2b65f3
--- /dev/null
+++ b/result_collection_api/update/restore.py
@@ -0,0 +1,39 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corporation
+# feng.xiaowei@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import argparse
+
+from utils import execute, main, get_abspath
+
+parser = argparse.ArgumentParser(description='Restore MongoDBs')
+
+parser.add_argument('-u', '--url',
+ type=str,
+ required=False,
+ default='mongodb://127.0.0.1:27017/',
+ help='Mongo DB URL for Backup')
+parser.add_argument('-i', '--input_dir',
+ type=str,
+ required=False,
+ default='./',
+ help='Input directory for the Restore.')
+parser.add_argument('-d', '--db',
+ type=str,
+ required=False,
+ default=None,
+ help='database for the restore.')
+
+
+def restore(args):
+ input_dir = get_abspath(args.input_dir)
+ cmd = ['mongorestore', '%s' % input_dir]
+ execute(cmd, args)
+
+
+if __name__ == '__main__':
+ main(restore, parser)