Linuxmysql regular backup and Compression
1. Check whether the mysql BACKUP command works.
Create a backup directory under the var directory and a mysql directory under the backup Directory to store mysql backup files
Cd to the/var/backup Directory
mysqldump -uroot -pwh5268925 zhaochao > mysql/zhaochao.sql
If yes, zhaochao. SQL backup files will be available under/var/backup/mysql.
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + Mi60tL2osbi33b3Fsb48L3A + signature + xNrI3cjnz8LL + cq + o6yxo7TmzsS8/export vcD4KPHA + Signature = "brush: SQL; "> JIRA_FILE_NAME = zhaochao-'date + % Y % m % d % H % M % s '; cd/var/backup/mysql/mysqldump-uroot-pwh5268925 zhaochao >$ {JIRA_FILE_NAME }. sqltar-zcvf implements jira_file_name1_. SQL .tar.gz $ {JIRA_FILE_NAME }. sqlrm-rf $ {JIRA_FILE_NAME }. SQL
3. Run the script to check whether the script can be correctly executed.
Cd to the/var/backup Directory to run the./mysql-backup.sh script, if correct, the/var/backup/mysql directory will generate a backup file named with time and compressed
4. Set the timer and regularly execute the mysql-backup.sh script
Create the crontest. cron file under/var/backup as follows:
15,30,45,59 * * * * /var/backup/mysql-backup.sh
Execute the script every 15 minutes.
5. Add the timer file to the timer.
crontab crontest.cron
6. Check whether the scheduled task is added to crontab-l in the system.
[root@iZ23l2efmpqZ backup]# crontab -l15,30,45,59 * * * * /var/backup/mysql-backup.sh
7. Cancel the scheduled task crontab-r
[root@iZ23l2efmpqZ backup]# crontab -l15,30,45,59 * * * * /var/backup/mysql-backup.sh[root@iZ23l2efmpqZ backup]# crontab -r [root@iZ23l2efmpqZ backup]# crontab -lno crontab for root