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: mariadb needs root@"IP" to access database in container #10

Open
wants to merge 1 commit into
base: main
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
6 changes: 4 additions & 2 deletions backup-docker-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ for i in $CONTAINER; do
$i /usr/bin/mysqldump -u root $MYSQL_DATABASE | gzip > $BACKUPDIR/$i-$MYSQL_DATABASE-$TIMESTAMP.sql.gz
done
elif docker exec $i test -e /usr/bin/mariadb-dump; then
# Get a list of databases in the container
DATABASES=$(docker exec -e MYSQL_PWD=$MYSQL_PWD $i mariadb -uroot -s -e "show databases" | grep -Ev "(Database|information_schema|performance_schema|mysql)")
# Get the IP of the DB-Container
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $i);
# Get a list of databases in the container
DATABASES=$(docker exec -e MYSQL_PWD=$MYSQL_PWD $i mariadb -uroot -h $IP -s -e "show databases" | grep -Ev "(Database|information_schema|performance_schema|mysql)")
# Loop through each database and create a backup
for MYSQL_DATABASE in $DATABASES; do
# Start Backup
Expand Down