Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 1.06 KB

setup-mongo-backup-strategy-on-linux-server.md

File metadata and controls

38 lines (24 loc) · 1.06 KB

Setup Mongo Backup Strategy on Linux Server

Step 0: Check if mongo is running on sever.

service mongod status

Step 1: place the script https://github.com/vijaykrishnavanshi/server-stuff/blob/master/mongobackup.sh to any particular path.

Step 2: Configure script variable according to your mongo setup.

Step 3: Change the permission of the script:

chomd +x /path/to/script/mongobackup.sh

Step 4: Add a crontab that will run the script on a repeat interval.

crontab -e

Step 5: Enter the following lines

# MongoDB Backup
00 00 * * * /path/to/script/mongobackup.sh

This will create a cronjob that will take the backup at every midnight.

If you want to read more about crontab and the pattern in front. Read this - https://www.computerhope.com/unix/ucrontab.htm

If you want to test the different patterns, try this - https://crontab.guru/

Credit: https://pranavprakash.net/2017/02/04/automate-mongodb-backups-using-cron-and-shell-script/