这篇文章将为大家详细讲解有关mysqldump如何备份脚本,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
mysql_full_backup.sh
#!/bin/sh
#Created by Clark 201710131716
source /data/mysqldata/scripts/mysql_env.ini
DATA_PATH=/data/mysqldata/backup/mysql_full
DATA_FILE=${DATA_PATH}/dbfullbak_`date +%F`.sql.gz
LOG_FILE=${DATA_PATH}/dbfullbak_`date +%F`.log
MYSQL_PATH=/usr/local/mysql/bin
MYSQL_DUMP="${MYSQL_PATH}/mysqldump -u${MYSQL_USER} -p${MYSQL_PASS} -S /data/mysqldata/${HOST_PORT}/mysql.sock -A -R -x --default-ch
aracter-set=utf8"
echo > $LOG_FILE
echo -e "=== Jobs started at `date +%F' '%T' '%w` ====\n" >>$LOG_FILE
${MYSQL_DUMP} | gzip > $DATA_FILE
echo -e "*** Excuted finshed at `date +%F' '%T' '%w`====" >>$LOG_FILE
echo -e "*** Backup file size: ` du -sh ${DATA_FILE}`====\n" >>$LOG_FILE
echo -e "---- Find expired backup and delete those files ----" >>${LOG_FILE}
for tfile in $(/bin/find $DATA_PATH/ -mtime +6)
do
if [ -d $tfile ] ; then
rmdir $tfile
elif [ -f $tfile ] ; then
rm -f $tfile
fi
echo -e "---- Delete file:$tfile -----" >> ${LOG_FILE}
done
echo -e "\n==== Jobs ends at `date +%F' '%T' '%w` ====\n" >> $LOG_FILE
关于“mysqldump如何备份脚本”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。