Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/bin/bash
  2. # Script for full/incremental backup of mariadb.
  3. export PATH=/usr/bin
  4. LOG=/var/log/backupDB.log
  5. [[ $(pgrep ${0}) ]] && echo "Another backup process is in progress, terminated." >> $LOG && exit 1
  6. FULLDAYS=3 # Number of days between full backups
  7. FULL=1 #full backup flag
  8.  
  9. USER=user
  10. PASS=*******
  11.  
  12. BACKUPDIR=/mnt/mysql_data/back
  13. LASTFULL=$(grep full-backuped ${BACKUPDIR}/*/xtrabackup_checkpoints | tail -1 | awk -F\: '{print $1}')
  14. INCRBASEDIR=$(dirname ${LASTFULL})
  15. [[ $(find ${LASTFULL} -mtime -${FULLDAYS} ) ]] && FULL=0
  16. case ${FULL} in
  17. 0) innobackupex --user=${USER} --password=${PASS} --compress --incremental --incremental-basedir=${INCRBASEDIR}
  18. ;;
  19. 1) innobackupex --user=${USER} --password=${PASS} --compress ${BACKUPDIR}
  20. ;;
  21. *) echo "FULL flag is out of range" >> $LOG ; exit 1
  22. ;;
  23. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement