Skip to content

Instantly share code, notes, and snippets.

View mitul-srashtasoft's full-sized avatar
🏠
Working from home

mitul-srashtasoft

🏠
Working from home
View GitHub Profile
@baniol
baniol / mongodb_backup.md
Last active August 15, 2022 18:58
MongoDB automatic backup

Maintaining even a small mongodb application in production requires regular backups of remotely stored data. MongoDB gives you three ways to acomplish it. In this post I'm using monogodump command for creating a backup and mongorestore for recreating the data. The purpose of this writing is to provide a simple way of periodic database dumps from a remote server to a Dropbox cloud storage.

Remember that for using mongodump you have to have a mongod process running.

Dumping a database

Suppose that you want make a backup of your books database.

To create a dump use mongodump -d books -o which will result in a book folder containing bson files with all collections.