Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This file contains the user/password combination to connect to the database
- source creds.sh
- DATE=`date +%Y%m%d`
- instancedirectory="/var/lib/"
- retval=-1
- backupdirectory="${1}"
- exportconfig="${2}"
- socket="${instancedirectory}/mysql.sock"
- config="${instancedirectory}/mysql.cnf"
- targetdirectory="${backupdirectory}/${DATE}/"
- if [ -z ${backupdirectory} ] || [ -z ${exportconfig} ]
- then
- echo "usage: ./backup.sh <backup directory> <export config>"
- else
- if [ -d ${backupdirectory} ]
- then
- echo "Starting backup to ${backupdirectory}...";
- innobackupex --user=${user} --password=${password} --defaults-file=${config} --socket=${socket} "${targetdirectory}" --tmpdir=/scratch/xtrabackups/tmpdir/ --no-timestamp --databases=${exportconfig} --slave-info;
- retval=$?
- if [ ${retval} -eq 0 ]
- then
- echo "Backup complete!";
- echo "Preparing to apply logs...";
- innobackupex --apply-log ${targetdirectory}
- retval=$?
- if [ ${retval} -eq 0 ]
- then
- echo "Logs have been applied and the backup has been prepared.";
- else
- echo "Unable to apply logs to the backup!";
- fi
- else
- echo "Error backing up to ${backupdirectory}!";
- fi
- else
- echo "${backupdirectory} does not exist!"
- fi
- fi
- ### Example of export config file
- ## Specific database tables
- # database.table1
- # database.table2
- ## Entire database
- # mysql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement