#!/bin/bash
# export and backup the activity.sql
mysqldump -uname -password activity --skip-lock-tables > /home/public_html/mysql_auto_backup/activity.sql
#zip the code and activity.sql
cd /home/public_html/mysql_auto_backup/
tar -zcvf /home/public_html/mysql_auto_backup/activity$(date +%Y%m%d%H%M).tar.gz activity.sql
#delete the activity.sql
rm -f /home/public_html/mysql_auto_backup/activity.sql
#delete backup zip 10 days ago
DAYS=10
find /home/public_html/mysql_auto_backup/ -name "activity*" -type f -mtime +$DAYS -exec rm {} \;