time backup mysql data

1.mkdir database_bak

2.vi /usr/sbin/bak.sh

rq='date+%Y%m%d'
tar zcvf datbase_bak/mysql$rq.tar.gz /usr/local/mysql/data
mysqldump --all-databases -u username -ppassword> database_bak/$rq.sql

3.chmod +X /usr/sbin/bak.sh

4.vi /etc/crontab
01 2*** root /usr/sbin/bak.sh

5./etc/rc.d/init.d/crond restart

你可能感兴趣的:(sql,mysql)