How To Dump Mongodb By Using Mongodump Tool with Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/dump-mongodb-using-mongodump-tool-examples/
PINTEREST
PINTEREST
INSTAGRAM

Mongodb provides a lot of flexibilities to the application developers and system administrators. As we know mongodb is an nosql database server. Standard Sql database servers provides different tools to dump and backup given database. Mongodb provides mongodump tool for dump and backup operations.

Check MongoDB Service Status

First we should check the status of the mongodb. We can use systemctl command which is provided by popular Linux distributions.

Check MongoDB Service Status
Check MongoDB Service Status

Dump MongoDb Database

We only need to specify the hostname of the mongodb database server. We will use  --host option in order to specify the hostname. In this example we will dump remote host named poftut1 . This will backup all databases to the file named dump .

Only Dump Specified Database

We do not need to dump all databases. We can specify the database we want to dump. We will use --db option in order to specify the database name. In this example we will only dump the database named school

Only Dump Specific Collection

We can also specify specific collection. We will use --collection option in order to specify the collection’s name. In this example we will dump the collection named students in database school .

Dump and Compress

Dumping big databases or collections will create a lot data with big size. If we need to do dump multiple times in a day the disk will be full. We can compress the dumped data by using gzip or similar compression tools. We will redirect the output of dump to the gzip with --out - option. In this example we also set the compressed dump name with the current date.

LEARN MORE  Arp-Scan Command Tutorial With Examples

For more information about compression look following tutorials.

http://www.poftut.com/7z-command-tutorial-examples-compress-extract-files-linux/

http://www.poftut.com/gzip-command-tutorial-examples-linux/

 

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/dump-mongodb-using-mongodump-tool-examples/
PINTEREST
PINTEREST
INSTAGRAM

Leave a Reply

Your email address will not be published.