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