If i want to do a generic backup for all databases in mongodb, is it that all i have to do is:
$ mongodump
And if i want to restore the latest dump i've created, all i need to do is:
$ mongorestore
The Mongodump command dumps a backup of the database into the “. bson” format, and this can be restored by providing the logical statements found in the dump file to the databases. The Mongorestore command is used to restore the dump files created by Mongodump.
To import data to a MongoDB database, you can use mongoimport to import specific collections data, or you can use mongorestore to import a binary (BSON) full database backup. The exported database file must be stored locally on the same machine as your client.
The backups are stored in the directory that you have specified with the --out option in command line. If you do not specify any output dir the backup will be placed to ./dump directory. With the mongorestore you have to specify the directory where you have dumped before as a command line argument.
On sharded environment the backup will be flattened if you use mongodump through a mongos. After restore you will have to re-shard the collections. so restoring not always effortless. See documentation: http://docs.mongodb.org/manual/tutorial/backup-small-sharded-cluster-with-mongodump/
You can dump directly the db folders too, check the cli options.
For sharded clusters you can check the possibilities here: http://docs.mongodb.org/manual/administration/backups/#sharded-cluster-backups
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With