By Time Backup MySQL script

By Time Backup MySQL script

#!/bin/bash
BASE_PATH=/data/dump/
JIRA_FILE_NAME=ZY798-`date +%Y%m%d%H%M%S`;
cd /usr/local/mysql/bin/
mysqldump -h127.0.0.1 -P3306 -uroot -proot ZY798 > ${BASE_PATH}${JIRA_FILE_NAME}.txt
cd ${BASE_PATH}
tar -zcvf ${JIRA_FILE_NAME}.txt.tar.gz ${JIRA_FILE_NAME}.txt
rm -rf ${JIRA_FILE_NAME}.txt

Four o'clock every day to perform:

0 4 *  *  *  /var/backup/ZY798-mysql-backup.sh

PS: regular tasks related commands
crontab -emodify the scheduled tasks
crontab -ldisplay the user all the scheduled tasks
/sbin/service crond start// start the service
/sbin/service crond stop// close the Services
/sbin/service crond restart// restart the service
/sbin/service crond reload// reload the configuration
/sbin/service crond status// check the service status

Guess you like

Origin blog.csdn.net/xianhenyuan/article/details/92792324