Linuxmysql regular backup and Compression

Source: Internet
Author: User

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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.