MongoDB script to backup replication set locally to a ubuntu 14.04 server

mongodb

I would like to make a Daily Backup of my MongoDB from a replication set running from ubuntu 14.04 server.

End goal would be to get a daily backup and write the backup to a remote or local share – ubuntu.

Can I batch the mongodump command?

Please help me on this

Best Answer

You can execute mongodump from the remote server as mentioned below:

mongodump --host <ip-of-mongodb-server> --port <port-number-of-mongod> --out <some-directory>

This is required mongo server to be accessible from the remote server.

This dump file can be then compressed and archived on remote host or s3.

If the mongo server is not accessible from remote host, in that case you can execute mongodump on local mongodb server and copy it to remote or local share.