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

Fix: Recognize container that uses multiple DBs #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chris922
Copy link

The docker container doesn't work with my linked in mariadb container. It has issues, because the env. variable *_ENV_MYSQL_DATABASE is not available.

I changed the behaviour so that this variable isn't required anymore. If it is not available mydumper will create a backup for all databases.

@@ -16,7 +16,7 @@ RUN \

RUN \
apt-get -y update && \
apt-get -y install mydumper && \
apt-get -y install mydumper git sudo && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why git?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced the hooks to be able to create a simple script that commits the changes after every backup automatically. So it was required to have git available inside the docker.

# Based on the mode, different default options will be set.
#

MODE=${MODE:-BACKUP}

case "${MODE^^}" in
'BACKUP')
OPTIONS=${OPTIONS:-}
;;
'COMPRESSED_BACKUP')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just overwriting OPTIONS?

@@ -112,7 +131,7 @@ then
echo "DONE"

echo "===> Starting backup..."
exec su -pc "mydumper ${CLI_OPTIONS}" ${USER}
sudo -u ${USER} mydumper ${CLI_OPTIONS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the container properly "stoppable" (i.e. docker stop container vs docker kill container) with just sudo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I haven't tested this yet. Changing from exec to sudo was required to be able to call the hooks afterwards, because exec will not continue with the execution of this script.

#
# Call after hooks
#
if [ -d "/hooks" ] && ls /hooks/*.after 1> /dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWESOME IDEA! 👍

@chris922
Copy link
Author

Oh I just wanted to create a pull request for the first commit b62f0f4. The other two commits just contained stuff I needed for my internal purpose and it wasn't planned to include them in this pull request (e. g. that's why I just added git - of course it is in general not required)

@domibarton domibarton changed the base branch from develop to master May 16, 2019 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants