Database backups in a docker installation


I’ve just installed ownCloud and I’d like to make backups, to prevent data loss. Unfortunately I’m a bit confused on what the best way is to backup the database.

On this ownCloud page, it says to use rsync to backup the Docker volume of the database container:

But then on this ownCloud page at step 3., it says I should run mysqldump inside the database container in order to create a backup of the database:

Should I use the latter, since it is more recent? But then I’m also not sure on what steps to take to restore the database, as that is not specified there. I found this page, but there the file ends in .bak, instead of in .sql, so I’m not sure if the instructions apply. It really seems like I’m reading three different stories.

Thanks for any help!

Edit: Sorry for formatting the links like this, it seems that new users are not allowed to add links to their posts :frowning:


Using mysqldump is the way to go. The blog post is pretty old and outdated (and we should probably remove it). Please check out the instructions from the MariaDB container at Docker Hub for more details. Quick ref:

## dump
$ docker exec some-mariadb sh -c 'exec mariadb-dump --all-databases -uroot -p"$MARIADB_ROOT_PASSWORD"' > /some/path/on/your/host/all-databases.sql

## restore
$ docker exec -i some-mariadb sh -c 'exec mariadb -uroot -p"$MARIADB_ROOT_PASSWORD"' < /some/path/on/your/host/all-databases.sql


Thanks for clarifying, I will do it this way. I guess it makes sense when looking at the filesizes: 33Mb (after compression) for docker and 150Kb for the sqldump.

1 Like