Content
How to backup and restore from/to a container - clarifications needed
Added by Vincent Nguyen over 2 years ago
Good morning,
I'm really have a hard time to understand the backup and restore process
Context:
I have a OpenProject 12.1.0 running in a docker container on a Synology NAS, with the /pgdata and /assets folder mounted and accessible on the host
Based on the documentation, I quote:
" If you are using the all-in-one container, then you can simply backup any local volumes that you chose to bind-mount with the -v
option when launching the container"
I assumed therefore that when starting a new fresh version of the container with a new version, simply mounting the above folders (with the same parameters for the rest, such as SECRET) would allow to restore the server to it's operational state (as is the case with many other docker containers I run).
But when doing so, the new container detects there is an install, but returns an SQL error so stops.
So I assume that the above only backups the data volume , but not the database itself ? So I need to also run the
" docker exec -e PGPASSWORD=openproject -it $OP_CONTAINER_NAME pg_dump -U openproject -h localhost -d openproject -x -O > openproject.sql " command ? (which in itself is problematic, since I don't have easy root access to the main host running the container)
Which is coherent with the restore procedure here:
Restoring an OpenProject backup
But then... in this procedure they refer to importing the database inside the container, but make no mention of the pgdata and assets folders, which are recreated during this process. I suspect that if I overwrite pgdata and assets folder with my backup data, it will create errors due to a mismatch with the container SQL database
Also:
- While I can easily maintain a sync backup of the pgdata and assets volumes, I can't do that easily for the database
- Restoring is really a complicated process which requires root access to the host (since it executes the docker command)
Now, I therefore tried to use the backup command in the sysadmin page, using the backup token procedure
I could easily generate the backup, but then... how do I restore it ? The zip file generated seems to only include the sql database and the attachments, but I could not find documentation on how to restore from that backup file, all documentations I have found refer to manual backup procedures
Also, is there any way to automate this backup to a Samba/NFS share, and run it periodically ?
Thanks for any clarification you can share