Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Script for full/incremental backup of mariadb.
- export PATH=/usr/bin
- LOG=/var/log/backupDB.log
- [[ $(pgrep ${0}) ]] && echo "Another backup process is in progress, terminated." >> $LOG && exit 1
- FULLDAYS=3 # Number of days between full backups
- FULL=1 #full backup flag
- USER=user
- PASS=*******
- BACKUPDIR=/mnt/mysql_data/back
- LASTFULL=$(grep full-backuped ${BACKUPDIR}/*/xtrabackup_checkpoints | tail -1 | awk -F\: '{print $1}')
- INCRBASEDIR=$(dirname ${LASTFULL})
- [[ $(find ${LASTFULL} -mtime -${FULLDAYS} ) ]] && FULL=0
- case ${FULL} in
- 0) innobackupex --user=${USER} --password=${PASS} --compress --incremental --incremental-basedir=${INCRBASEDIR}
- ;;
- 1) innobackupex --user=${USER} --password=${PASS} --compress ${BACKUPDIR}
- ;;
- *) echo "FULL flag is out of range" >> $LOG ; exit 1
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement