1 ##############################################################################
2 # Copyright (c) 2016 ZTE Corporation
3 # feng.xiaowei@zte.com.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
13 from utils import execute, main, get_abspath
15 parser = argparse.ArgumentParser(description='Backup MongoDBs')
17 parser.add_argument('-u', '--url',
20 default='mongodb://127.0.0.1:27017/',
21 help='Mongo DB URL for Backups')
22 parser.add_argument('-o', '--output_dir',
26 help='Output directory for the backup.')
28 parser.add_argument('-d', '--db',
31 default='test_results_collection',
32 help='database for the backup.')
37 out = get_abspath(args.output_dir)
38 now = datetime.datetime.now()
39 out = os.path.join(out, '%s__%s' % (db, now.strftime('%Y_%m_%d_%H%M%S')))
40 cmd = ['mongodump', '-o', '%s' % out]
43 if __name__ == '__main__':