Skip to content
Snippets Groups Projects
Commit 39e3a0b1 authored by Dmitriy Safronov's avatar Dmitriy Safronov
Browse files

entrypoint

parent 8801741e
No related branches found
No related tags found
No related merge requests found
Pipeline #8232 passed
......@@ -26,13 +26,18 @@ backup () {
test -z "${MYSQL_PASS}" || ( echo "Setting [MYSQL_PASS] environment variable is insecure, use passwordfile [/password] instead"; PASS="${MYSQL_PASS}" )
test -f /password && PASS="$(cat /password)"
unset MYSQL_HOST MYSQL_PORT MYSQL_USER MYSQL_PASS
test -n "${MYSQL_FILE}" && BACKUP_PREFIX="${MYSQL_FILE}" || BACKUP_PREFIX="${HOST}_${PORT}"
unset MYSQL_HOST MYSQL_PORT MYSQL_USER MYSQL_PASS MYSQL_FILE
# Create final Backup Directory
mkdir -p "${BACKUPDIR}"
test -d "${BACKUPDIR}" || ( echo "There might be an error: no final backup dir. Will create one..."; mkdir -p "${BACKUPDIR}" )
test -w "${BACKUPDIR}" || ( echo "There might be an error: no write access to final backup dir. Will change rights..."; chmod -Rc u+w "${BACKUPDIR}" )
# Create temp Backup Directory
TEMPDIR="${BACKUPDIR}/.${NOW}"
test -d "${TEMPDIR}" || mkdir -p "${TEMPDIR}"
test -w "${TEMPDIR}" || ( echo "There might be an error: no write access to temp backup dir. Will change rights..."; chmod -Rc u+w "${TEMPDIR}" )
# Create temp Backup Config
CONFIG="$(mktemp)"
......@@ -61,11 +66,13 @@ backup () {
# ZIP BACKUP #
cd $TEMPDIR
tar -zcvf ${HOST}_${PORT}-${NOW}.tar.gz *.sql
tar -zcvf ${BACKUP_PREFIX}-${NOW}.tar.gz *.sql
echo "---"
du -h ${BACKUP_PREFIX}-${NOW}.tar.gz
cd - > /dev/null
# MOVE BACKUP TO BACKUP DIR #
mv -f ${TEMPDIR}/${HOST}_${PORT}-${NOW}.tar.gz "${BACKUPDIR}"
mv -f ${TEMPDIR}/${BACKUP_PREFIX}-${NOW}.tar.gz "${BACKUPDIR}"
# CLEANUP #
rm -rf ${TEMPDIR}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment