Skip to content

Instantly share code, notes, and snippets.

@datn
Last active June 18, 2021 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datn/a4a466bb713eba8c18ba7558aa848efd to your computer and use it in GitHub Desktop.
Save datn/a4a466bb713eba8c18ba7558aa848efd to your computer and use it in GitHub Desktop.
Backing up data from Docker volumes

Backing up data

All data for Wikibase and the Query Service is stored in Docker volumes. You can create compressed copies of these volumes to use as backups or to hand off to other users.

Volume backups will only work if you use the same image when restoring / using the backup data. If you are backing up your mysql data you may also want to just take an SQL dump.

You can see all Docker volumes created by using the following command:

docker volume ls | grep wikibase-docker

You can grab a zip of each volumes by doing the following:

docker run -v wikibase-docker_mediawiki-mysql-data:/volume -v /tmp/wikibase-data:/backup --rm loomchild/volume-backup backup mediawiki-mysql-data

You, or someone else, can then restore the volume by doing the following:

docker run -v wikibase-docker_mediawiki-mysql-data:/volume -v /tmp/wikibase-data:/backup --rm loomchild/volume-backup restore mediawiki-mysql-data

Backing up data using mysqldump

If using volume-backup for the database does not work because of InnoDB tables (check here), you can achieve data backup using mysqldump.

Backing up with mysqldump

docker exec wikibase-docker_mysql_1 mysqldump -u wikiuser -psqlpass my_wiki > backup.sql

Restoring from mysqldump backup file

docker exec wikibase-docker_mysql_1 mysql -u wikiuser -psqlpass my_wiki < backup.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment