Advertisement
Guest User

Untitled

a guest
Oct 8th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.25 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin"
  4. export PATH
  5. BASE=/home/mysql.xtrabackup
  6.  
  7. echo `date` Starting backup.
  8.  
  9. rm -rf ${BASE}/*
  10.  
  11. ulimit -n 204800
  12. DATABASES="`mysql -BNe 'select distinct table_schema from information_schema.tables where table_schema not in (\"information_schema\", \"apachelogs\")' | xargs echo`"
  13.  
  14. SAFE_SLAVE="--slave-info"
  15.  
  16. PASSWORD=`cat ~/.my.cnf | grep password | cut -f2 -d=`
  17.  
  18. innobackupex --defaults-file=/etc/mysql/my.cnf --databases="${DATABASES}" ${BASE} --password=${PASSWORD} ${SAFE_SLAVE} > $BASE/lastlog 2>&1
  19.  
  20. OK=`tail -1 $BASE/lastlog | grep "innobackupex: completed OK!"`
  21.  
  22. if [ -z "$OK" ]; then echo Backup stage 1 was not OK; exit 1; fi
  23.  
  24. DIR=`ls -1 ${BASE}/ |grep ^[0-9]`
  25.  
  26. innobackupex ${BASE}/${DIR} --apply-log  > ${BASE}/${DIR}/innobackupex.1apply-log 2>&1
  27.  
  28. OK=`tail -1 ${BASE}/${DIR}/innobackupex.1apply-log | grep "innobackupex: completed OK!"`
  29.  
  30. if [ -z "$OK" ]; then echo Backup stage 2 was not OK; exit 1; fi
  31.  
  32. echo `date` Backup process finalized.
  33. #"CHANGE MASTER TO MASTER_HOST='172.25.10.2', MASTER_USER='repl', MASTER_PASSWORD='slavepassword', MASTER_LOG_FILE='${BIN_LOG}', MASTER_LOG_POS=${BIN_POS}; \""
  34. #echo `date` Please check manualy.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement