How to avoid "Database Contains Existing Confluence Data" with Docker container?
Asked by Charlie Misonne:

Hi fellow Community members!

I'm migrating a Confluence instance from a regular setup to Docker/ Kubernetes with Atlassian's official image.  
My database already contains the data and I don't need to run the database setup wizard again.

I'm using the *ATL_DB_TYPE, ATL_JDBC_USER, ATL_JDBC_URL, ATL_JDBC_PASSWORD* environment variables. This generates the confluence.cfg.xml file when the container starts.

When navigating to Confluence I get **Database Contains Existing Confluence Data.**

I noticed this in the config file when comparing it with the classic setup:

1. There is no *\<property name="hibernate.setup"\>true\</property\>*line.
2. *\<setupStep\>xxxxx\</setupStep\>* so is not set to *complete*. (I forgot what the actual value was.

So I added that "missing" line and set the \<setupStep\>Complete\</setupStep\> and restarted the container.  
This time Confluence does start. I'm getting some other database errors but I think they are related to a database migration we ran.

Does anyone have experience with this? I read about [How to Generate a New confluence.cfg.xml](https://confluence.atlassian.com/confkb/how-to-generate-a-new-confluence-cfg-xml-425461512.html) but I do not expect a container to need that kind of manual actions.


Answers:
author: Yevhen
body: [@Charlie Misonne](/t5/user/viewprofilepage/user-id/502263) you will have to migrate home directory that has config file - if it exists it won't be recreated. So, when migrating, I'd start with migrating home directory to a volume (PVC in case of K8s) and run the container with JDBC envs. This should be enough.

Btw, have you checked <https://github.com/atlassian-labs/data-center-helm-charts>?

comments: author: Charlie Misonne
body: Hi Yevhen!

Thanks for the quick reply.

Ok I have a PVC already for the home directory but as I'm just testing at the moment I didn't move the whole home directory yet. I will give it a shot.

I'm not using the helm chart for this project. Perhaps I'll use it in the future. Thanks!


author: Charlie Misonne
body: [@Yevhen](/t5/user/viewprofilepage/user-id/3965218)

In the Kubernetes environment I'm using another database host. I now copied the home directory from the original environment but of course the database settings are now pointing to the previous host. The environment variables are not replacing the old values.

So should I manually adapt the values in the confluence.cfg.xml in my PCV to use the new database?


author: Yevhen
body: Hey Charlie! I guess you do not need an entire home dir. Just some critical directories. Unfortunately, I am not well versed in what are those for Confluence (I am a Bamboo guy :) )

If you have a PVC bound to a PV, I'd probably start a throw away pod with a command like tail -f /dev/null, mount home using this PVC, and then kubectl cp files in there. I'd probably use Confluence image for that to avoid any permission issues. Once done start Confluence the normal way.

You can also build an image with your current home directory and use it in an initContainer (just once) that will copy files to mounted directory.

It is possible that chmod or chown may be required - it depends on your storage backend and security policies.

You asked a good question, and I think we'll be working on migrate-to-k8s guides.


author: Yevhen
body: [@Charlie Misonne](/t5/user/viewprofilepage/user-id/502263) yes, if DB settings changed, you'll need to update them in cfg file.

Python entrypoint in the image will generate the file, however, it'll skip it if it exists. You should even see some logs saying that. So yes, it looks like moving cfg file to a volume and making edits there is the fastest way to migrate.


author: Charlie Misonne
body: Alright got it.

By copying the original file and making some manual changes it works indeed.

Thanks!


Tags: confluence-server

docker

server