Open link in a new tab

Content

Expand project menu

Transfer DB to Kubernetes

We are trying to transfer our instance from a docker-compose install to kubernetes / helm-chart. The documentation on restoring does not mention the helm-install and we are unsure of how to import the DB-dump into the postgres-pod(s). Do you have any suggestions and if so, would it make sense to add this to the documentation?

Message actions

Hi Daniel,

Restoring helm chart is almost the same as restoring the backup for docker compose.

https://www.openproject.org/docs/installation-and-operations/operation/restoring/#using-docker-compose

First step would be to install OpenProject on Kubernetes.
After that you can use the docker compose steps but would need to use the kubectl instead of docker-compose command.

So you would stop the web and worker container first:

kubectl scale deployment  --replicas=0 -n openproject openproject-worke
kubectl scale deployment  --replicas=0 -n openproject openproject-worker-default

After that you can drop the existing database:

kubectl exec -it -n openproject openproject-postgresql-0 -- psql -U postgres -c 'drop database openproject;'

this command will ask you for the password of the postgres user if you don't know it you should be able to get it with this command:

kubectl get secret -n openproject openproject-postgresql -o json |jq -r '.data."postgres-password"' |base64 --decode && echo

Now you can recreate the database:

kubectl exec -it -n openproject openproject-postgresql-0 -- psql -U postgres -c 'create database openproject owner openproject;'

Now copy the openproject.sql to the postgres container:

kubectl cp -n openproject openproject.sql openproject-postgresql-0:/tmp

Then you can open the database console:

kubectl exec -it -n openproject openproject-postgresql-0 -- psql -U openproject

Here we use the openproject user so you need to use a different password this can be found here:

kubectl get secret -n openproject openproject-postgresql -o json |jq -r '.data.password' |base64 --decode && echo

In the database console you need to add the following commands:

\c openproject
\i /tmp/openproject.sql

Now you can run the helm upgrade command again this will that start the seeder to migrate the database:

helm upgrade --create-namespace --namespace openproject --install openproject openproject/openproject

Best regards

Tizian