Simple bash script to take nightly
Put it in a crontab for nightly backups. First open crotab:
Create a new line (entry) in crontab and paste the below cron task:
#mongodb #backup #cron #cronjob #coderwall #mongodump #bash
MongoDB
backups:#!/bin/sh
DIR=`date +%m%d%y`
DEST=/db_backups/$DIR
mkdir $DEST
mongodump -h <your_database_host> -d <your_database_name> -u <username> -p <password> -o $DEST
NOTE:
db_backups folder shoud already be created by mkdir /db_backups
.Put it in a crontab for nightly backups. First open crotab:
sudo crontab -e
Create a new line (entry) in crontab and paste the below cron task:
45 1 * * * ../../scripts/db_backup.sh
NOTE:
here our script is called db_backup.sh, should you use your own script name here. and make it executable by chmod +x /your/ full_path/scripts/db_backup.sh
#mongodb #backup #cron #cronjob #coderwall #mongodump #bash