Error message: "Confluence tables already exist in the selected database"
Asked by gar:

I'm attempting to migrate a Confluence server and it's not working. I installed postgresql on the new server (same version as old), and created a database to match the old one. I "dumped" the old one, and loaded it into the new one with no errors. I also installed tomcat on the new server, and performed a new install of Confluence using the WAR file. When I go to my new server (<http://server:8080/confluence>) I'm brought to the "Configure Database" page. I select "Direct JDBC Connection" to match the old installation, enter in the correct URL and user name and password to match the old one, yet, I always get the error message shown above. I don't understand the error message - I was hoping the tables already exist in the database, but confluence isn't so happy. Was it expecting a database with no tables? I tried that too and the end result is always the same - tomcat dies. Any help would be appreciated.


Answers:
author: gar
body: This was never resolved. I'm closing it since I don't have time to figure it out.


author: twong_atlassian
body: Verify that confluence-installdir/confluence/WEB-INF/classes/confluence-init.properties == the place where you unzipped the home dir.

Verify that the confluence.cfg.xml in the home folder lists that the setup-step is complete. Verify that your hostname for the db in confluence.cfg.xml is sensible.

comments: author: Andrew Snyder
body: I ran into the same issue that "gar" reported above where I was trying to migrate Confluence from one server to another. I got the same error saying that tables existed in the database, which was expected since the database was from another instance, but I couldn't proceed with the Confluence setup wizard.

I found that the home directory mentioned in my \<install_dir\>/confluence/WEB-INF/classes/confluence-init.properties file was incorrect, and it was pointing to a blank folder. Modifying that to point to the desired confluence-home folder based on the location that I loaded the confluence-home files into worked. I re-ran the "stop-confluence.sh" script and the "start-confluence.sh" script, and Confluence started up as expected.

Thanks Tim Wong!


author: Harry Chan
body: Hi, did you copy the Confluence home directory? I think this is what's missing.

comments: author: gar
body: I did not, but I will try it. Is there some particular file(s) that is needed? Does the entire directory get copied even if the original server was a stand-alone and the new one is running off tomcat?


author: Harry Chan
body: The entire directory needs to be copied and configs changed if required.


author: Naren
body: Like Harry said, you may like to refer the below link to cross check whether your confluence-init.properties is pointing towards the correct confluence-home directory -

<https://confluence.atlassian.com/display/CONFKB/Setup+Wizard+Prompts+User+to+Overwrite+Database+During+Upgrade>


author: gar
body: That didn't fix it, in fact, it's a bit worse now. The old confluence home directory was tarred up and copied over, and the confluence-init.properties files (both of them, one under tomcat, one under confluence install directory) were modified to point to the new confluence home directory. Now I can't even start the tomcat manager to get to the deployed apps - attempting that kills tomcat.

I believe I noted this before, the previous install was standalone, the new one runs under tomcat. The confluence-init.properties files therefore look a bit different. Also, the old confluence version was 4.1.7, the new one is 4.3.7. It sounds like a config issue - but which file needs modifying?


author: fsim
body: There's also the possibility that the status of the confluence.cfg.xml is not set to complete:

```
&lt;setupStep&gt;complete&lt;/setupStep&gt;
```

Can you attach the contents of confluence.cfg.xml here? (from the migrated Confluence Home Directory)

comments: author: gar
body: Here you go:

\<?xml version="1.0" encoding="UTF-8"?\>

\<confluence-configuration\>  
\<setupStep\>complete\</setupStep\>  
\<setupType\>custom\</setupType\>  
\<buildNumber\>3144\</buildNumber\>  
\<properties\>  
\<property name="admin.ui.allow.daily.backup.custom.location"\>false\</property\>  
\<property name="admin.ui.allow.manual.backup.download"\>false\</property\>  
\<property name="admin.ui.allow.site.support.email"\>false\</property\>  
\<property name="attachments.dir"\>${confluenceHome}/attachments\</property\>  
\<property name="confluence.license.hash"\> ommitted \</property\>  
\<property name="confluence.license.message"\>ommitted\</property\>  
\<property name="confluence.setup.server.id"\>BTHW-SEQO-X2Z2-WLSW\</property\>  
\<property name="confluence.webapp.context.path"\>\</property\>  
\<property name="hibernate.c3p0.acquire_increment"\>1\</property\>  
\<property name="hibernate.c3p0.idle_test_period"\>100\</property\>  
\<property name="hibernate.c3p0.max_size"\>30\</property\>  
\<property name="hibernate.c3p0.max_statements"\>0\</property\>  
\<property name="hibernate.c3p0.min_size"\>0\</property\>  
\<property name="hibernate.c3p0.timeout"\>30\</property\>  
\<property name="hibernate.connection.driver_class"\>org.postgresql.Driver\</property\>  
\<property name="hibernate.connection.isolation"\>2\</property\>  
\<property name="hibernate.connection.password"\>ommitted\</property\>  
\<property name="hibernate.connection.url"\>jdbc:postgresql://localhost:5432/confluence\</property\>  
\<property name="hibernate.connection.username"\>postgres\</property\>  
\<property name="hibernate.database.lower_non_ascii_supported"\>true\</property\>  
\<property name="hibernate.dialect"\>net.sf.hibernate.dialect.PostgreSQLDialect\</property\>  
\<property name="hibernate.setup"\>true\</property\>  
\<property name="lucene.index.dir"\>${confluenceHome}/index\</property\>  
\<property name="webwork.multipart.saveDir"\>${confluenceHome}/temp\</property\>  
\</properties\>  
\</confluence-configuration\>


author: Daniel Borcherding
body: Hello Gar,

I just wanted to echo what was said above. It sounds like you did not move your \<confluence_home\> direcotry to the appropraite location. An upgrade should never prompt you to configure your database. The connection should already be set up in your \<confluence_home\>/confluence.cfg.xml.

One of the things that I noticed is that it appears that you are trying to migrate from the standalone to a WAR install and upgrade all in the same go. It may be a good plan for you to try only one of these steps at a time. It also may be a good plan to examine if you really have a business case to use the WAR installation. This setup tends to complicate installation and support of your instance. If you can get away with the standalone install it is probably best.

When installing your new Confluence all you should need to do is change your \<confluence_install\>/confluence/WEB-INF/classes/confluence-init.properties to point to your existing \<confluence_home\> directory. That and a startup of your instance should be all that is required to trigger the upgrade tasks for Confluence

comments: author: gar
body: Thanks for the reply Daniel. I agree I shouldn't try upgrading at the same time, but there seems to be no older versions of WAR files to download. Does anyone know where those can be found on the Atlassian site?

As for migrating a server from a stand-alone to a containerized one, I also agree it might be a bit involved, but I'm not willing to give in just yet. It's just a business preference to run this under Tomcat. Surely I'm not the first one to try this sort of migration, but so far, it appears as if I am as I have found no documentation.


author: gar
body: Nevermind about the archive WAR file - I found it using the search on the atlassian site.


author: Daniel Borcherding
body: Gar,

I am not suggesting that you not use the WAR install. That can be some compelling business reasons to do so. Even a strong business prefernece would be enough to motivate this.

My suggestion is that you seperate the upgrade and WAR migration into two steps.

First upgrade your standalone Confluence to the latest version. We have a document that outlines how to do this below.

<https://confluence.atlassian.com/display/DOC/Upgrading+Confluence>

Once you are at the latest version of Confluence you can focus on getting over to the WAR install. All you would need to do in this is install the WAR version and point the \<confluence_install\>/confluence/WEB-INF/classes/confluence-init.properties at your existing \<confluence_home\> just as you would do for the upgrade.

Does that make more sense?


author: gar
body: Yes, it makes sense. Rather than upgrade, I located the 4.1.6 EAR/WAR file to match our current installation and used that on the new server. Tomcat doesn't crash anymore, but still no joy. I deployed it using the Tomcat deployment manager (also tried it by putting the war file directly into the webapps directory), pointed the confluence-init.properties file to my confluence home directory - and I still get the "Configure database" Confluence setup page (it also asks for license info first). It's acting like a new install.


Tags: migration