Question

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
  • Where are the backups from the mongodump stored?
  • How to i specify a specific dump for all databases to be restored?
Was it helpful?

Solution

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

OTHER TIPS

restore all mongorestore --host= --port= --username= --authenticationDatabase= --nsInclude "."

backup all mongodump --ssl --host --port -p --authenticationDatabase -u -p --out

If you want to backup databases use: mongodump --ssl --host --port -p --authenticationDatabase -u -p --out

if the database has ssl enabled include the --ssl flag if you don't include the --out mongodump will create a "/dump" directory. inside the dump or specified backup directory you'll find directories with the names of your databases, inside each of them, you'll find the backups files, for each collection you'll find a ".bson" and a ".metadata.json"

To restore all the databases use: mongorestore --ssl --host= --port= --username= --authenticationDatabase= --nsInclude "."

Again if the database has ssl enabled include the --ssl flag if not just remove it. the "--nsInclude" flag tell mongorestore which databases or collections you want to restore. Examples: --nsInclude=test.users (this will backup the users collection of the database test, and therefore will fail if the path to the dump is anything but the path to the users.bson of that particula database)

To include all the database and all the collections use --nsInclude=. or --nsInclude . then define the path to all the collection directories of your backup

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top