SHARE
TWEET

Untitled

a guest Mar 20th, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # This file contains the user/password combination to connect to the database
  3. source creds.sh
  4. DATE=`date +%Y%m%d`
  5. instancedirectory="/var/lib/"
  6. retval=-1
  7. backupdirectory="${1}"
  8. socket="${instancedirectory}/mysql.sock"
  9. config="${instancedirectory}/mysql.cnf"
  10. targetdirectory="${backupdirectory}/${DATE}/"
  11. if [ -z ${backupdirectory} ]
  12. then
  13.         echo "usage: ./backup.sh <backup directory>"
  14. else
  15.         if [ -d ${backupdirectory} ]
  16.         then
  17.                 echo "Starting backup to ${backupdirectory}...";
  18.                 innobackupex --user=${user} --password=${password} --defaults-file=${config} --socket=${socket} "${targetdirectory}" --tmpdir=/scratch/xtrabackups/tmpdir/ --no-timestamp --slave-info;
  19.                 retval=$?
  20.                 if [ ${retval} -eq 0 ]
  21.                 then
  22.                         echo "Backup complete!";
  23.                         echo "Preparing to apply logs...";
  24.                         innobackupex --apply-log ${targetdirectory}
  25.                         retval=$?
  26.                         if [ ${retval} -eq 0 ]
  27.                         then
  28.                                 echo "Logs have been applied and the backup has been prepared.";
  29.                         else
  30.                                 echo "Unable to apply logs to the backup!";
  31.                         fi
  32.                 else
  33.                         echo "Error backing up to ${backupdirectory}!";
  34.                 fi
  35.         else
  36.                 echo "${backupdirectory} does not exist!"
  37.         fi
  38. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top