Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement