Create file called dbbackup.sh
put below mention lines in it and save.
nano /home/dbbackup/dbbackup.sh
#!/bin/bash
echo "Starting to backup database"
mysqldump --opt -uroot asterisk > /home/dbbackup/asterisk_`date '+%Y-%m-%d'`.sql
echo "backup done..."
echo "Please wait, Compressing backup file..."
/bin/gzip /home/dbbackup/asterisk_`date '+%Y-%m-%d'`.sql
echo "gzip done..."
echo "Deleting 3 Days old backups"
find /home/dbbackup -iname '*.sql.gz' -type f -mtime +3 -print | xargs rm -f \{\} \;
put below line in cron file
00 02 * * * /home/dbbackup/dbbackup.sh
Comments
Post a Comment