vi /backups/mongodb_backup.sh
#!/bin/bash
date1=`date +%d%m%Y_%H%M%S`
export path1=/backups/mongodb_backup
OUTPUTDIR="$path1/$date1"
/usr/bin/find /backups/mongodb_backup/* -type d -mtime +30 -exec rm -r {} \; 2> /dev/null
mongodump -o $path1/$date1
/bin/tar -zcvf /backups/mongodb_backup/backup_$date1.tar.gz $path1/$date1
rm -rf $path1/$date1
exit
#Schedule in crontab:-
crontab -e
0 0 * * * /backups/mongodb_backup.sh > /dev/null
#!/bin/bash
date1=`date +%d%m%Y_%H%M%S`
export path1=/backups/mongodb_backup
OUTPUTDIR="$path1/$date1"
/usr/bin/find /backups/mongodb_backup/* -type d -mtime +30 -exec rm -r {} \; 2> /dev/null
mongodump -o $path1/$date1
/bin/tar -zcvf /backups/mongodb_backup/backup_$date1.tar.gz $path1/$date1
rm -rf $path1/$date1
exit
#Schedule in crontab:-
crontab -e
0 0 * * * /backups/mongodb_backup.sh > /dev/null
No comments:
Post a Comment