18.6. Backup/Restore of MongoDB

Backup is done per database with the following where world is the database.

mongodump -d world

resulting in

dump
└── world
    ├── city.bson
    └── city.metadata.json

This structure may be zipped and transported between users. If necessary, and if appropriate, it may be handled by git in some project.

Restoring a database is done by

mongorestore -d world --drop dump/world

The two prorams mongodump, and mongorestore might have to be installed separately. You may find them in the mongo-utilities package which obviously must be installed.