SHARE
TWEET

Untitled

a guest Mar 20th, 2017 102 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. exportconfig="${2}"
  9. socket="${instancedirectory}/mysql.sock"
  10. config="${instancedirectory}/mysql.cnf"
  11. targetdirectory="${backupdirectory}/${DATE}/"
  12. if [ -z ${backupdirectory} ] || [ -z ${exportconfig} ]
  13. then
  14.         echo "usage: ./backup.sh <backup directory> <export config>"
  15. else
  16.         if [ -d ${backupdirectory} ]
  17.         then
  18.                 echo "Starting backup to ${backupdirectory}...";
  19.                 innobackupex --user=${user} --password=${password} --defaults-file=${config} --socket=${socket} "${targetdirectory}" --tmpdir=/scratch/xtrabackups/tmpdir/ --no-timestamp --databases=${exportconfig} --slave-info;
  20.                 retval=$?
  21.                 if [ ${retval} -eq 0 ]
  22.                 then
  23.                         echo "Backup complete!";
  24.                         echo "Preparing to apply logs...";
  25.                         innobackupex --apply-log ${targetdirectory}
  26.                         retval=$?
  27.                         if [ ${retval} -eq 0 ]
  28.                         then
  29.                                 echo "Logs have been applied and the backup has been prepared.";
  30.                         else
  31.                                 echo "Unable to apply logs to the backup!";
  32.                         fi
  33.                 else
  34.                         echo "Error backing up to ${backupdirectory}!";
  35.                 fi
  36.         else
  37.                 echo "${backupdirectory} does not exist!"
  38.         fi
  39. fi
  40.  
  41.  
  42. ### Example of export config file
  43. ## Specific database tables
  44. # database.table1
  45. # database.table2
  46. ## Entire database
  47. # mysql
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