Hi I am running xwiki in docker instance. I am also running the mysql database in a Docker container.
I am running it using the following docker compose file `
version: '2'
networks:
xwiki-nw:
driver: bridge
services:
xwiki:
image: "xwiki:lts-mysql-tomcat"
container_name: XWiki
depends_on:
- db
ports:
- "12456:8080"
environment:
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_DATABASE=${DB_DATABASE}
- DB_HOST=xwiki-db
volumes:
- ./data/xwiki-data:/usr/local/xwiki
# - ./data/tomcat-conf:/usr/local/tomcat/conf
networks:
- xwiki-nw
db:
image: "mysql:5.7"
container_name: xwiki-db
volumes:
- ./data/mysql-data:/var/lib/mysql
- ./xwiki.cnf:/etc/mysql/conf.d/xwiki.cnf
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_USER=${DB_USER}
- MYSQL_DATABASE=${DB_DATABASE}
networks:
- xwiki-nw`
I am trying to back up the Xwiki database using the following script
#!/bin/bash
# Get a list of all the databases in the container
databases=$(docker exec xwiki-db mysql --user=xwiki --password="MY_PASSWORD" -e 'SHOW DATABASES')
# Iterate through the list of databases and dump each one to a separate file
for database in $databases; do
docker exec xwiki-db mysqldump --add-drop-database --user=xwiki --password="MY_PASSWORD" $database > ./backup/$database.sql
done
cd backup
rm -rf Database.sql information_schema.sql mysql.sql performance_schema.sql sys.sql
After backing up I am trying to restore the data using the following script.
#!/bin/bash
# Iterate through the list of database backups and restore each one to the database in the container
cd backup
cwd=$(pwd)
files=$(ls $cwd)
docker exec backup-xwiki-db mysql --user=xwiki --password="MY_PASSWORD" -e "SET FOREIGN_KEY_CHECKS=0;"
for file in $files; do
tempfile="${file%.*}"
echo $tempfile
docker exec backup-xwiki-db mysql --user=xwiki --password="MY_PASSWORD" -e "DROP DATABASE IF EXISTS $tempfile;"
docker exec backup-xwiki-db mysql --user=xwiki --password="MY_PASSWORD" -e "CREATE DATABASE IF NOT EXISTS $tempfile DEFAULT CHARACTER SET utf8;"
cat $tempfile.sql | docker exec backup-xwiki-db mysql --user=xwiki --password="MY_PASSWORD" $tempfile
done
docker exec backup-xwiki-db mysql --user=xwiki --password="MY_PASSWORD" -e "SET FOREIGN_KEY_CHECKS=1;"
cd ..
#pass=$(cat ./data/xwiki-data/data/hibernate.cfg.xml | grep passw| head -1 | sed -e 's/^.*<prop.*password">//' | sed -e 's|</property>.*||')
#docker exec backup-xwiki-db mysql--user=xwiki --password="MY_PASSWORD" -e "SET PASSWORD FOR 'xwiki'@'localhost' = PASSWORD('$pass');"
After restoring the data I am unable to login to the XWiki instance.
I am getting the following error.
2023-11-03 14:37:00,411 [http-nio-8080-exec-2 - http://<my-ip>:12472/bin/loginsubmit/XWiki/XWikiLogin] WARN nticationFailureLoggerListener - Authentication failure with login [GeorgeAdmin]
What is the cause of the error and how can I correct it?
Thank you.