dump.sh

#!/bin/sh

TE=`date +%Y%m%d%H%M` #every minute
DATABASE=maxotm #database name
DB_USERNAME=xxxx #database username
DB_PASSWORD="xxxx" #database password
BACKUP_PATH=/data/mysql #backup path
#backup command
mysqldump $DATABASE | gzip > ${BACKUP_PATH}\/${DATABASE}_${DATE}.sql.gz
#just backup the latest 5 day
find ${BACKUP_PATH} -mtime +3 -name "*.*" -exec rm -f {} \;

定时执行备份

//crontab -e
//m h dom mon dow user command
//0 10 * * * /home/sh/mysql-backups/dump.sh