Regular backup of MySQL database using mysqldump in Linux

Source: Internet
Author: User

    #!/bin/bashpath=/bin:/sbin:/usr/bin:/usr/sbin:/usr/Local/bin:/usr/Local/sbin:~/bin export PATH export LANG=en_us. utf-8Savedir=/Log/database_bak/CD"$savedir"       Time="$ (date +"%Y-%m-%d %H:%M:%s")"mysqldump-U [My_user]-p[my_pwd] [db_name] > [db_name]-"$time". sql

Note here that the following-p does not have spaces directly added [MY_PWD]

The sh script is then placed in the/log/sh/directory and given execute permissions, and finally into the Linux timed task Crond, adding the following script:

   run-parts databasebak.sh  01  * * * * * * root Run-parts/etc/cron.hourly  4  * * * Root run-parts/ Etc/cron. daily  22  4  * * 0  Root Run-parts/etc/cron. weekly  42  1  * * Root run-parts/etc/cron. monthly  02  5  * * * root sh/log /sh/databasebak.sh  

Finally save good after restart Crond,service crond restart can!

Regular backup of MySQL database using mysqldump in Linux

Related Article

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.