What backup and restore commands are available in mongodb
This article introduces what backup and restore commands are available in mongodb, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
Backup:
Mongodump-uroot-ppassword-- port=27017-- authenticationDatabase=admin-h hostname-d databasename-o / data/backup/mongodump/
-the address of the server where the h:MongDB is located, for example: 127.0.0.1. Of course, you can also specify the port number: 127.0.0.1 27017.
-d: database instance that needs to be backed up, for example: database_name
-o: where the backup data is stored
Mongo full database recovery
$mongorestore-h host-d database_name-directoryperdb / mg_data/backup/mongodump/database_name
Single collection backup
Mongos > mongoexport-h dbhost-d dbname-c collectionname-f collectionKey-o dbdirectory
-h: address of the server where MongoDB is located
-d: database instance to be restored
-c: collection to be restored
-f: fields to be exported (omitted to all fields)
-o: indicates the name of the exported file
Single collection recovery
Mongos > mongoimport-d dbhost-c collectionname-type csv-headerline-file
-type: indicates the file format to import
-headerline: specify that the first row is not imported, because the first row is the column name
-file: indicates the path of the file to be imported
At the same time, you need to make a physical backup of the library, usually a snapshot
Lvcreate-L10G-s-n data_snapshot / dev/vg01/lv01
After the project team has finished, then remove this snapshot and ok it.
# lvremove / dev/vg01/data_snapshot
If you need to restore, the steps are as follows
Mkdir / snapshort
Mount / dev/datavg01/vg01 / snapshort/
Stop the mongodb, and the backup files of the cp snapshot go to the corresponding data directory of mongo.
Start mongo, and you can.
# mongodb bulk insert data drill Test #
For (var iTuno Bandi)