Backup mongodb script

I need to run mongodump every time in my database.

How can I automate this intelligently? Every day I want to create a new folder created with a timestamp and dump data inside.

Thank.

+3
source share
3 answers

Take a look

https://github.com/micahwedemeyer/automongobackup

Otherwise, use standard tools like cron or shell scripts to transfer the mongodump call.

+8
source

You can use the cron scheduler to run the mongodump script shell every day. Or you can even use iCal by creating an event, editing it and choosing Run Script.

0

script. cron .

ssh root@hostname "mongodump --db myDatabaseName --out /tmp/mongo-backup ; zip -r /tmp/mongo-backup$(date "+%Y.%m.%d").zip  /tmp/mongo-backup ; rm -rf /tmp/mongo-backup" ;
scp root@hostname:/tmp/mongo-backup$(date "+%Y.%m.%d").zip ./

script .

  • Runs the mongodump script and creates a ZIP file, for example: mongo-backup2017.03.02.zip
  • Download this file via SCP to your local machine.
0
source

All Articles