Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When detecting innobackupex version, just parse the first line. #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions s3backup
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ KEYFILE="${S3BACKUP_DIR}/key"
LOCKFILE="${S3BACKUP_DIR}/lock"
LOGFILE="/var/log/s3backup.log"
CURRENT_DATE=$(date +%Y%m%d)
MINOR_SUPPORTED_VERSION="23"
MINOR_SUPPORTED_VERSION="230"
TRUE="1"
FALSE="0"

Expand Down Expand Up @@ -135,7 +135,7 @@ __check_mysql_credentials () {
# --- Function: __check_xtrabackup_version
__check_xtrabackup_version () {
local CURRENT_VERSION
CURRENT_VERSION=$($IBEX_CMD --version 2>&1 | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e 's/\.//g' )
CURRENT_VERSION=$($IBEX_CMD --version 2>&1 | head -n1 | sed -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e 's/\.//g' )
if [ "$CURRENT_VERSION" -lt "$MINOR_SUPPORTED_VERSION" ]
then
echoerror "Please install xtrabackup 2.3 or higher."
Expand Down Expand Up @@ -233,24 +233,24 @@ case $CMD in
echoerror "MySQL service is not running!. Please ensure mysql is running before running a backup."
fi
__check_mysql_credentials
echoinfo "Backup in progress, please wait. Log written to ${LOGFILE}"
touch "${LOCKFILE}" || echoerror "Failed to create lock file. Please review the configuration."
${IBEX_CMD} --encrypt=AES256 --encrypt-key-file="${KEYFILE}" --stream=xbstream --compress --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} . 2>>"${LOGFILE}" | $PV_CMD | ${GOF3R_CMD} put -b "${S3_BUCKET_NAME}" --endpoint="${AWS_REGION}" -k "${S3_BACKUP_PATH}"/"${CURRENT_DATE}"/"${S3_BACKUP_NAME}".xbcrypt
STATUS=(${PIPESTATUS[@]})
IBEX_STATUS=${STATUS[0]}
S3_STATUS=${STATUS[1]}
if [ "$IBEX_STATUS" -ne 0 ]
then
echoerror "Xtrabackup failure!. Plese check the log and try again."
fi
if [ "$S3_STATUS" -ne 0 ]
then
echoerror "S3 Bucket Transfer failed!"
fi
echoinfo "Upload of ${S3_BACKUP_NAME}.xbcrypt to path ${S3_BACKUP_PATH}/${CURRENT_DATE} on Bucket ${S3_BUCKET_NAME} complete"
rm -f "${LOCKFILE}"
exit 0
;;
echoinfo "Backup in progress, please wait. Log written to ${LOGFILE}"
touch "${LOCKFILE}" || echoerror "Failed to create lock file. Please review the configuration."
${IBEX_CMD} --encrypt=AES256 --encrypt-key-file="${KEYFILE}" --no-lock --slave-info --safe-slave-backup --stream=xbstream --compress --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} . 2>>"${LOGFILE}" | $PV_CMD | ${GOF3R_CMD} put -b "${S3_BUCKET_NAME}" --endpoint="${AWS_REGION}" -k "${S3_BACKUP_PATH}"/"${CURRENT_DATE}"/"${S3_BACKUP_NAME}".xbcrypt
STATUS=(${PIPESTATUS[@]})
IBEX_STATUS=${STATUS[0]}
S3_STATUS=${STATUS[1]}
if [ "$IBEX_STATUS" -ne 0 ]
then
echoerror "Xtrabackup failure!. Plese check the log and try again."
fi
if [ "$S3_STATUS" -ne 0 ]
then
echoerror "S3 Bucket Transfer failed!"
fi
echoinfo "Upload of ${S3_BACKUP_NAME}.xbcrypt to path ${S3_BACKUP_PATH}/${CURRENT_DATE} on Bucket ${S3_BUCKET_NAME} complete"
rm -f "${LOCKFILE}"
exit 0
;;
restore|full-restore)
if [ -z "$2" ]
then
Expand Down