How to take Backup of MongoDB on ubuntu 20.04 LTS - TechBeginner

Welcome to TechBeginner.in, Tech Beginner provides technical blog for Online Linux Tutorials, Ubuntu Tutorials, Redhat Tutorials and CentOS 7, Configuration of server like Web Server, Application server, Database server, Window server, networking, html, css, java script, php, wordpress, opencart, magento, joomla and etc.

How to take Backup of MongoDB on ubuntu 20.04 LTS

Share This


 

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.

 

No comments:

Post a Comment