MySQL Command Automatic backup

Source: Internet
Author: User

1. Create and edit the file/usr/sbin/bakmysql, command:

Vi/usr/sbin/bakmysql

The contents are as follows:

 db_ user= "root"  2  db_passwd= "root"  Span style= "color: #008080;" >3  db_name= "Db_test"  4  # the directory for stories your backup file.you shall change this dir  5  backup_dir= "/usr/software/backup/mysqlbackup"  6  # date format for backup file (dd-mm-yyyy)  7  time= "$ (date +"%y%m%d%h%m%s ")"  8  9  $mysqldump-u $db _user-p$db_passwd $ Db_name > "$backup _dir/$db _name" _ "$time. sql"  

2. Modify the file Bakmysql property to make it executable;

chmod +x/usr/sbin/bakmysql

3.创建定时任务crontab–e  #进入编辑界面,内容如下* * *./usr/sbin/bakmysql #上一行命令的 "." No, you can.

# 10 23 is a daily 23:10 execution Bakmysql files, backing up the database in the path /usr/software/backup/mysqlbackup under

MySQL Command Automatic backup

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.