Tip: MySQL-Backup and XWiki

Hi,

I just realized that a mysqldump is heavily disrupting xwiki operation at my site. I’m doing mysql database dumps once during the night. And recently troubles started to emerge. The number of threads of XWiki went through the roof regularly which was seemingly to be caused by broken solr data. Now I discovered that a mysqldump was the cause of this.

XWiki-Setup:

  • docker
  • container: xwiki:16-mysql-tomcat
  • mysql:5.7

To fix this, I did the following:

  1. shutdown of the xwiki
  2. removed solr data (rm -rf ./wiki-data/data/jobs/status/3/solr ./wiki-data/data/cache/solr ./wiki-data/data/store/solr)
  3. started xwiki again

What I further did:

  • What did not work:

    Switching from embedded solr to remote solr

    • solr instance in separate docker container
    • changed solr config in xwiki.cfg:
      solr.type=remote
      solr.remote.url=http://xwikistable-solr:8983/solr/xwiki
    • It seems so xwiki.cfg is no longer used. It has to be xwiki.properties. So I stay with the embedded solr for now
  • Changed Backup procedure

    • Shutdown XWiki
    • Shutdown solr
    • execute mysqldump
    • start solr again
    • wait 20 Seconds for solr to come up
    • start XWiki again

For now it seems to work.

The script, I’m using is not that useful, because it’s heavily dependent on my environment. Nevertheless maybe it’s useful for you:

#!/bin/bash -e
# -e causes the script to exit, if any error occurs

declare -rx PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
declare -rx LC_ALL=C
declare -rx BASEDIR=/opt/wiki
declare -rx LOG_FILE=$BASEDIR/mysql-backup-log/mysql-backup.log
declare -rx STATUS_FILE=$BASEDIR/mysql-backup-log/backup_status

mylog() {
echo "$(date) : $*" >>$LOG_FILE
echo "$(date) : $*"
}

stdout_logger() {

cat 2>&1 | while read line;do
mylog "$line"
done

}

{
echo PENDING >$STATUS_FILE
mylog "***** starting backup procedure for xwiki database *****"
mylog "stopping monit wiki watcher"
systemctl stop monit 2>&1 | stdout_logger
cd /opt/wiki
mylog "shutting down wiki"
docker-compose stop xwikistable 2>&1 | stdout_logger
mylog "shutting down solr"
docker-compose stop solr 2>&1 | stdout_logger
mylog "executing backup"
docker-compose exec -T mysqlbackup \
bash -c "mysql_dump_exec" 2>&1 | stdout_logger
mylog "starting solr again"
docker-compose start solr 2>&1 | stdout_logger
sleep 20
mylog "starting wiki again"
docker-compose start xwikistable 2>&1 | stdout_logger
mylog "waiting until starting monit again"
sleep 120
mylog "starting monit wiki watcher again"
systemctl start monit 2>&1 | stdout_logger
echo OK >$STATUS_FILE
mylog "***** backup procedure for xwiki database finished *****"
} >/dev/null 2>&1 &