Brent Keller

MongoDB Backup and Restore

Useful commands to backup and restore a MongoDB database. See the MongoDB docs for more information.

Backup

mongodump -h localhost:27017 -d <database-name> -o <path\to\store\backup>

# example
mongodump -h localhost:27017 -d my-db -o c:\data\mongo\2021-11-08-my-db-backup

Restore

cd <directory containing the backup data>
mongorestore --host localhost --port 27017 --username USER_NAME --password SAMPLE_PASSWORD --db DATABASE_NAME .