Self-executed MySQL Data Backup in Ubuntu

Source: Internet
Author: User
1. First, add the scheduled task to the list. The system scans the task list every minute to check whether the task is to be executed at the current time./etc/crontab: # mhdommondowusercommand01 ** & n

1. First, add the scheduled task to the list. The system scans the task list every minute to check whether the task is to be executed at the current time.

 
  1. /etc/crontab: 
  2. # m h dom mon dow user    command 
  3.   0 1  *   *  *   root    /home/fzw/db.sh 
  4.   0 2  *   *  *   root    /home/fzw/auto.sh 

M: minute h: hour dom: day of month mon: month dow: day of week user: user command: Task command

2./Home/fzw/db. shBackup, compression

 
  1. mysqldump -x -u root -h 127.0.0.1 -p 123 -c --hex-blob --default-character-set=utf8 --compact --no-create-db --no-create-info --databases dbname > /home/fzw/136/136_4d`date +%Y%m%d`.sql 
  2. rar a /home/fzw/136/136_4d`date +%Y%m%d`.rar /home/fzw/136/136_4d`date +%Y%m%d`.sql 

3./Home/fzw/auto. shCopy192.168.2.143

 
  1. #!/usr/bin/expect -f 
  2. set date [exec date +%Y%m%d] 
  3. set password 123  
  4. spawn scp /home/fzw/136/136_4d$date.rar fzwadmin@192.168.2.143:/home/fzwadmin/136/136_4d$date.rar 
  5. set timeout 300 
  6. expect "fzwadmin@192.168.2.143's password:" 
  7. send "$password\r" 
  8. expect eof 
  9. #interact 

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.