Tag:home backup and Recovery cti res gdb gpo output export filename
-------------------MongoDB Data Import and Export-------------------1, export tools:mongoexport 1, concept: The Mongoexport tool in MONGODB can export a collection to a file in JSON or CSV format. You can specify the exported data item by parameter, or you can export the data based on the specified criteria. 2, Syntax: mongoexport-d dbname-c collectionname-o file--type json/csv-f field&nb Sp parameter description: -D: Database name -C: Collection name -o: Output filename --type: output format, default For json -F: Output field, if-type is CSV, you need to add-f "field name" 3, example: sudo mongoexport-d mongotest-c users-o/home/python/desktop/mongodb/users.json--type json-f "_id,user_id , User_name,age,status " 2, data import:mongoimport 1, Syntax: mongoimport-d dbname-c CollectionName--file filename--headerline--type json/csv-f field parameter description: -D: Database name & nbsp -c:collection name --TYPE: Imported format default json -F: Imported field names --headerline: If the imported format is CSV, you can use the header of the first row as the imported field & nbsp --file: Files to import 2, example: sudo mongoimport-d mongotest-c users--file/h Ome/mongodump/articles.json--type json -------------------MongoDB Backup and Recovery-------------------1, MongoDB database backup 1, grammar: mongodump-h dbhost-d dbname-o dbdirectory parameter says : -H:MONGDB server address, for example: 127.0.0.1, you can also specify the port number:127.0.0.1:27017 -D: Database instances that need to be backed up, such as:test -o: Data storage location for backup, for example:/home/mongodu mp/, of course, the directory needs to be established in advance, this directory contains a backup of the database instanceData. 2, example: sudo rm-rf/home/momgodump/ sudo mkdir-p/home /momgodump sudo mongodump-h 192.168.17.129:27017-d itcast-o/home/mongodump/ &N Bsp -2, MongoDB database recovery 1, Syntax: mongorestore-h dbhost-d dbname--dir dbdirectory&nb sp; parameter or name: -H:MONGODB server address &NBSP ; D: db instance that needs to be recovered, such as test, which can also be different from the time of backup, such as test2 --dir: Where the backup data resides , such as:/home/mongodump/itcast/ --drop: When recovering, delete the current data and then restore the backed up data. That is, after the recovery, add the modified data after the backup will be deleted, use with caution! 2, instance: mongorestore-h 192.168.17.129:27017-d itcast_restore--dir/home/mongodump/itcast/
MongoDB Import Export and database backup