Database backups in a docker installation

Hello,

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:
https://owncloud.com/news/docker-series-pt-3-automatically-backup-and-restore-a-dockerized-owncloud/

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:
https://doc.owncloud.com/server/10.11/admin_manual/installation/docker/#upgrading-owncloud-on-docker

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 https://doc.owncloud.com/server/next/admin_manual/maintenance/backup_and_restore/restore.html#restore-the-database, 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:

Hi,

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

Hello,

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

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.