STEP 1:
mkdir /var/www/html/backup
STEP 2: Edit the file below.
nano /root/dbbackup.sh
STEP 3: Install mutt. Mutt is a text-based mail client along the lines of Pine or Elm.
yum -y install mutt
STEP 4: Paste the script below.
#!/bin/bash
echo "Starting to backup database"
mysqldump --opt -uroot -ppassword asterisk > /var/www/html/backup/vicidial-db_`date '+%Y-%m-%d'`.sql
echo "backup done..."
echo "Please wait, Compressing backup file..."
gzip /var/www/html/backup/vicidial-db_`date '+%Y-%m-%d'`.sql
echo "gzip done..."
echo " -- sending mail"
echo | mutt -s "Mysql Backup Done" emailaddress
echo "DONE"
STEP 5:
Save and exit.
STEP 6:
chmod 755 /root/dbbackup.sh
STEP 7:
crontab -e
STEP 8: Copy and paste the script below at the lower part of crontab.
### Fixing and Optimizing Database
30 1 * * 0 /usr/bin/mysqlcheck -ucron -p1234 --auto-repair --check --optimize --all-databases
### Weekend Database Back-up after operation every Sunday 2PM
0 2 * * 0 /root/dbbackup.sh
### Delete Database backup
24 0 * * 0 /usr/bin/find /var/www/html/backup -maxdepth 1 -name "vicidial-db*.*" -mtime +30 -print | xargs rm -f
STEP 9:
Save and exit
No comments:
Post a Comment