加入收藏 | 设为首页 | 会员中心 | 我要投稿 海南站长网 (https://www.0898zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

mysql的备份脚本共享

发布时间:2022-01-16 11:15:24 所属栏目:MySql教程 来源:互联网
导读:本篇内容介绍了mysql的备份脚本分享的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! #!/bin/bash ###############################################
     本篇内容介绍了“mysql的备份脚本分享”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
 
#!/bin/bash
#################################################################
#                                                               #
#       Purpose: MySQL backups                                  #
# This script does a full or incremental backup  #
# The full is done via mysqldump#
# The incremental is done via flush-logs option  #
# with mysqladmin#
#                                                               #
#                The script is also setup to email if a         #
#                failure occurs                                 #
#                                                               #
#       Assumptions:                                            #
#               1. Database is in Binary Update Log mode        #
#               2. The variables are set correctly              #
##
#Usage:mysql_backup [full|incremental]#
##
#                                                               #
#################################################################
#################################################################
#               INITILIAZE VARIABLES                            #
#################################################################
# Set the mode, full|incremental
# parameter is passed in
MODE=$1
# set the username to connect to mysql for the backup
MYSQLUSER=backup
# set the password to connect to mysql for the backup
MYSQLUSERPW=password
# set the Binary Update Logs Path
BINLOGPATH=/mysql/logs/emds01/mysql
# Set the binary Update Logs name
BINLOGNAME=viper2-bin
# set the backup path
BACKUPPATH=/export/home/mysql/backups
# set the email address for errors to be emailed to
EMAIL_ADDR=shenandoah.speers@cicadacorp.com
# set the log file
LOGFILE=$BACKUPPATH/logs/$HOSTNAME_$RUNDATE.log
# set the error log file
LOGERR=$BACKUPPATH/logs/ERRORS_$HOSTNAME_$RUNDATE.log
# set the number of days to keep the backups
DAYSTOKEEP=5
# set Run date
RUNDATE=`date +%Y%m%d%s`
# set hostname
HOSTNAME=`uname -n`
#################################################################
#               GLOBAL FUNCTIONS                                #
#################################################################
copyBinlogs() {
# copy binlogs to backup dir
echo "Copying binlogs"
for FILE in `cat $BINLOGPATH/$BINLOGNAME.index`
do
SFILE=(${FILE/*/

(编辑:海南站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!