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

DUMP_ON_RESTART is ignored on create #144

Open
vladikk007 opened this issue Nov 29, 2024 · 1 comment
Open

DUMP_ON_RESTART is ignored on create #144

vladikk007 opened this issue Nov 29, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@vladikk007
Copy link

I'm using docker volume to persist DB data. After container deletion and create again, it apply dump.sql so it restore DB even in cse DUMP_ON_RESTART is set to false. Could you please fix it? Thanks

@vladikk007 vladikk007 changed the title DUMP_ON_RESTART is ignored after create DUMP_ON_RESTART is ignored on create Nov 29, 2024
@jokesterfr
Copy link
Contributor

Hi!
thank you for reaching us.
This tool has been designed for short term tests, therefore persistence has never been required nor wanted for the our users until now.

For my own understanding of your use case, what is your testing case requiring a persistence database?

DUMP_ON_RESTART is meant to container restart only, it is used here:

# Restoring MySQL dumps
if [ ! -f $DUMP_LOCK ] || [ "$DUMP_ON_RESTART" = "true" ]; then
echo "* Restoring MySQL dump..."
[ ! -f "/dump.sql" ] && echo "Error: missing dump. Exiting" && exit 5
if [ "$DRY_RUN" = "true" ]; then
echo "(skipped)";
else
mysql -u "$MYSQL_USER" --host="$MYSQL_HOST" --password="$MYSQL_PASSWORD" "$MYSQL_DATABASE" < /dump.sql
fi
echo "* MySQL dump restored!"
if [ -n "$MYSQL_EXTRA_DUMP" ]; then
echo "* Restoring MySQL EXTRA dump(s)..."
mysql -u "$MYSQL_USER" --host="$MYSQL_HOST" --password="$MYSQL_PASSWORD" "$MYSQL_DATABASE" < "$MYSQL_EXTRA_DUMP"
fi
touch $DUMP_LOCK
else
echo "* Dump already performed (see DUMP_ON_RESTART)"
fi

This is why if you delete and start the container the lockfile would be void and the dump would occur again.

However if you want to prevent this code to even dump anything, you shall file a new PR introducing this new behavior.

I would suggest DUMP_ENABLED as a variable to manage this, defaulting to "true". And when set to false all the block L176 would be disabled, printing a message to the user "Dump has been disabled (see DUMP_ENABLED)".

If you have any question do not hesitate to ask,
Best,

@jokesterfr jokesterfr self-assigned this Jan 8, 2025
@jokesterfr jokesterfr added the enhancement New feature or request label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants