Crontab Scheduled BACKUP Database

Source: Internet
Author: User
Tags file permissions

Tag: EXEC database ROR RMS Erro scheduled backup local color div

1. Create a shell script file

CD usr

mkdir Dabackup

Vim backup.sh

Echo "-----------------------------">>/usr/dbbackup/Dbbackup.logEcho`Date+%y%m%d '"erms Database Backup Start">>/usr/dbbackup/Dbbackup.log/usr/local/mysql/bin/msyqldump-uroot-ppwd erms >>/usr/dbbackup/backup_ 'Date+%y%m%d '. SQLif[$?-eq0]; Then        if[-F"/usr/dabackup/backup_ ' Date +%y%m%d '. SQL"];Then 
Tar-czf/usr/dabackup/backup_ ' Date +%y%m%d ' Echo`Date+%y%m%d '"erms Database Backup Success">>/usr/dbbackup/Dbbackup.logElse Echo`Date+%y%m%d '"erms Database Backup fail!">>/usr/dbbackup/Dbbackup.logfiElse Echo`Date+%y%m%d '"erms Database Backup Error">>/usr/dbbackup/Dbbackup.logfiEcho "-----------------------------">>/usr/dbbackup/Dbbackup.logFind/usr/dbbackup/-mtime +7-name backup_\*-execRM-RF {} \;

Change backup.sh file Permissions chmod 755/usr/dabackup/backup.sh

2. Adding to a scheduled task

Backup once daily 3:30 A.M.

Crontab-e

 - 3 * * */usr/dbbackup/backup. SH

Crontab Scheduled BACKUP Database

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.