export MDATE=`date +%Y%m%d`

export MDATE2=`date +%Y-%m-%d`

export USER="백업계정"

export PASSWD="백업계정비밀번호"

export HOST="아이피"

export BACKUPDIR="백업경로"  ## /백업디렉토리/INCREMENTAL

export LOGDIR="로그경로"


touch $LOGDIR/INCRE _TRANS_$MDATE.log

epxort LOG="$LOGDIR/INCRE_TRANS_$MDATE.log"



function INCREMENTALTRANS() {    

echo "-----"| tee -a $LOG
echo `date +%Y-%m-%d' '%H:%M:%S` >> $LOG
echo "TRANSPORT  START" >> $LOG
echo "----" >> $FULLLOG

/usr/local/bin/sshpass -p $PASSWORD /usr/bin/ssh -T -oStrictHostKeyChecking=no $USER@$HOST <<EOF1
mkdir -p $BACKUPDIR/$MDATE
EOF1
/usr/local/bin/sshpass -p $PASSWORD scp -r /maria_backup/incre/$MDATE2* $USER@$HOST:$BACKUPDIR/$MDATE/
}


INCREMENTALTRANS
if [ $? = "0" ]; then
echo `date +%Y-%m-%d' '%H:%M:%S` >> $LOG
echo "INCREMENTAL TRANSPORT COMPLETE" >> $LOG
else
echo `date +%Y-%m-%d' '%H:%M:%S` >> $LOG
echo "INCREMENTAL TRANSPORT FAILED" >> $LOG
fi


'mysql' 카테고리의 다른 글

incre.sh  (0) 2018.02.19
full_trans  (0) 2018.02.19
backup crontab  (0) 2018.02.19
full backup  (0) 2018.02.19

export DATE=`date +%Y%m%d%H%M%S`

export USER="백업계정"

export PASSWD="백업계정비밀번호"

export PORT="포트숫자"

export BACKUPDIR="백업경로" ##기존 full.sh 백업경로

export DBCONF="/etc/my.cnf"

export FULLDIR="백업경로/full/" 

export INCDIR="$BACKUPDIR/incre"

export HOST="서버아이피"


if [ "$INCDIR" = "" ]; then

mkdir -p $BACKUPDIR/incre

fi


export INCLOGDIR="$BACKUPDIR/increlogs"

if [ "$INCLOG" = "" ]; then

mkdir -p $BACKUPDIR/increlogs/

touch $INCLOGDIR/incre_$DATE.log

export INCOG="$INCLOGDIR/incre_$DATE.log"

fi


function INCBACKUP() {
echo "-----"| tee -a $INCLOG
echo `date +%Y-%m-%d' '%H:%M:%S` >> $INCLOG
echo "BACKUP START" >> $INCLOG
echo "-----" >> $INCLOG

innobackupex --defaults-file=$DBCONF --user=$USER --password=$PASSWD --host==$HOST --port=$PORT --parallel=4 --tmpdir=$FULLDIR/tmp --extra-lsndir=$FULLDIR/tmp --incremental --incremental-basedir=$FULLDIR $INCDIR
}


INCBACKUP 
if [ $? = "0" ]; then
echo `date +%Y-%m-%d' '%H:%M:%S` >> $INCLOG
echo "BACKUP COMPLETE" >> $INCLOG
else
echo `date +%Y-%m-%d' '%H:%M:%S` >> $INCLOG
echo "BACKUP FAILED" >> $INCLOG
fi



'mysql' 카테고리의 다른 글

incre_trans.sh  (0) 2018.02.20
full_trans  (0) 2018.02.19
backup crontab  (0) 2018.02.19
full backup  (0) 2018.02.19

export MDATE=`date +%Y%m%d`

export USER="백업계정"

export PASSWD="백업계정비밀번호"

export PORT="포트숫자"

export BACKUPDIR="백업경로"  ##full backup 경로와 다름

export LOGDIR="로그경로"


touch $LOGDIR/FULL_TRANS_$MDATE.log

epxort LOG="$LOGDIR/FULL_TRANS_$MDATE.log"



function FULLTRANS() {

echo "-----"| tee -a $FULLLOG
echo `date +%Y-%m-%d' '%H:%M:%S` >> $LOG
echo "TRANSPORT  START" >> $FULLLOG
echo "----" >> $FULLLOG

/usr/local/bin/sshpass -p $PASSWORD /usr/bin/ssh -T -oStrictHostKeyChecking=no $USER@$HOST <<EOF1
mkdir -p $BACKUPDIR/$MDATE
EOF1
/usr/local/bin/sshpass -p $PASSWORD scp -r /maria_backup/full $USER@$HOST:$BACKUPDIR/$MDATE/
}


FULLTRANS
if [ $? = "0" ]; then
echo `date +%Y-%m-%d' '%H:%M:%S` >> $LOG
echo "FULLBACKUP TRANSPORT COMPLETE" >> $LOG
else
echo `date +%Y-%m-%d' '%H:%M:%S` >> $LOG
echo "FULLBACKUP TRANSPORT FAILED" >> $LOG
fi


'mysql' 카테고리의 다른 글

incre_trans.sh  (0) 2018.02.20
incre.sh  (0) 2018.02.19
backup crontab  (0) 2018.02.19
full backup  (0) 2018.02.19

###full backup ###

30 02 1 * * full.sh > fulllog_$(date + \%Y\%m\%d).log 2>&1

00 06 1 * * full_trans.sh 


###Incremental backup###

00 01 * * 0,1,2,3,4,5,6  incre.sh > increlog_$(date + \%Y\%m\%d).log 2>&1

00 04 * * 0,1,2,3,4,5,6  incre_trans.sh 



## backup delete  ##

00 05 * * 0 pre_full_rm_7.sh

30 05 * * 0 incre_rm_7.sh

30 00 1 * * full_rm.sh





'mysql' 카테고리의 다른 글

incre_trans.sh  (0) 2018.02.20
incre.sh  (0) 2018.02.19
full_trans  (0) 2018.02.19
full backup  (0) 2018.02.19

export DATE=`date +%Y%m%d%H%M%S`

export USER="백업계정"

export PASSWD="백업계정비밀번호"

export PORT="포트숫자"

export BACKUPDIR="백업경로"

export DBCONF="/etc/my.cnf"

export HOSt="서버아이피"


FULLDIR="$BACKUPDIR/full/"

if [ "$FULLDIR" = "" ]; then

mkdir -p $BACKUPDIR/full

fi


FULLLOGDIR="BACKUPDIR/logs"

if [ "$FULLLOG" = "" ]; then

mkdir -p $BACKUPDIR/full

touch $FULLLOGDIR/full_$DATE.log

export FULLLOG="$FULLLOGDIR/full_$DATE.log"

fi


export INCDIR="BACKUPDIR/incre"

if [ "$INCDIR" = "" ]; then

mkdir -p $BACKUPDIR/INCLOG/

touch $INCLOGDIR/INC_$DATE.log

export INCLOG="$INCLOGDIR/INC_$DATE.log"

fi


function FULLBACK() {
if [  "$FULLDIR" ="$FULLDIR" ]; then
echo "-----"| tee -a $FULLLOG
echo "FULL BACKUP FILE exist. Move pre-fullbackup files" | tee -a $FULLLOG
rm -rf $BACKUPIDR/full/*
echo "---"|tee -a $FULLLOG
echo "Delete Complete " |tee -a $FULLLOG
echo "----" | tee -a $FULLLOG
echo "----" | tee -a $FULLLOG
fi

echo `date +%Y-%m-%d' '%H:%M:%S` >> $FULLLOG
echo "BACKUP START" >> $FULLLOG
echo "----" >> $FULLLOG
innobackupex --defaults-file=$DBCONF --user=$USER --password=$PASSWD --host==$HOST --port=$PORT --parallel=64 --no-timestamp --tmpdir=$FULLDIR/tmp --extra-lsndir=$FULLDIR/tmp --backup $FULLDIR
}

FULLBACK >> $FULLLOG
if [ $? = "0" ]; then
echo `date +%Y-%m-%d' '%H:%M:%S` >> $FULLLOG
echo "BACKUP COMPLETE" >> $FULLLOG
else
echo `date +%Y-%m-%d' '%H:%M:%S` >> $FULLLOG
echo "BACKUP FAILED" >> $FULLLOG
fi



'mysql' 카테고리의 다른 글

incre_trans.sh  (0) 2018.02.20
incre.sh  (0) 2018.02.19
full_trans  (0) 2018.02.19
backup crontab  (0) 2018.02.19

+ Recent posts