purpose : Periodically dump the MySQL database, keeping only the last 5 days of backup
Operation Steps :
1. Create a new user test password dedicated to backup test123;
>grant select,show view,trigger,alter On * * to [email protected] ' localhost ' identified by ' test123 ';
>flush privileges;
# # # #运行mysqldump需一定的权限. For example, the minimum permission for a backup table is select, the backup view needs to show view permission, and the backup trigger needs to trigger permissions
2. Write scripts
#! /bin/bash
Backupdir=/data/mysql/mysqldump
Time= ' Data+%y%m%d%h '
mysqldump-utest-ptest123--single-transaction--all-databases |gzip > $backupdir/mysqldump_$time.sql.gz
Find $backdir-name ' mysqldump*.sql.gz '-type f-mtime +5--exec rm {} \; >/dev/null 2>&1
3. Add timed Tasks
#crontab-E
0 0 */1 * # # # # #脚本路径; start backup every 0 o'clock in the morning;
Save then ~ ~
A novice, if there is a mistake, please indicate
~~~~~~~~~~~~ Reprint please indicate the source
MySQL scheduled backup