MongoDB backup is very important, MongoDB provides us many option to take backup like Full back, Collection only backup, and restore it.
In this post, We will take MongoDB backup on Ubuntu 20.04 LTS
Take Full Backup of MongoDB
Here we do not specify database name, Whenever we are going to take full backup of MongoDB Database.
mongodump --host localhost --port 27017 --username root --password "password_here"
--authenticationDatabase admin --out /var/backup/mongodump
How to take only collections backup from MongoDB
Given command only take MongoDB’s collection by using the given command.
mongodump --host localhost --port 27017 --username root --password "123456"
--authenticationDatabase admin --db database_name_here --collection collection_name_here --out
/var/backup/mongodump
To Restore MongoDB Database
By use the given command, We will able to restored the MongoDB’s Database
mongorestore --host localhost --port 27017 --username root --password "password"
--authenticationDatabase admin --db database_name_here --drop
/var/backup/mongodump/databasename_here
Conclusion
In this post, We have successfully take backup of MongoDB on ubuntu linux, Still have any query please comment below.