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