Cannot restore Confluence from existing database
Asked by Mark Hylas:

Hi! Thanks in advance to anyone who can assist.

I've been trying to reconnect a fresh install to an existing database after something on my server went awry. The data in the database is in tact when I examine it.

When I edit the confluence.cfg.xml file to include the name of the existing database \[yes, my spelling and credentials are correct\] and then restart the confluence service, I receive the exact error described here: <https://confluence.atlassian.com/confkb/confluence-does-not-start-due-to-spring-application-context-has-not-been-set-218278311.html>

However, none of the ten things listed seem to be the cause of the issue. All of the fixes listed have been attempted.

Is there any possible way I can extract the content from this database at this point?


Answers:
author: AnnWorley
body: Hi Mark,

The steps I suggest are:

1. Create a new blank database of the same DBMS (postgres, MySQL, etc)
2. Install a new instance of Confluence of the same version as your old one, using the blank database of the same DBMS during the setup wizard.
3. After logging in to make sure the instance is up, shut it down
4. Backup \<Confluence_Home\>/confluence.cfg.xml
5. Edit only the JDBC URL, user name and password in confluence.cfg.xml to authenticate to the "real" database with your data in it.
6. Make sure no unexpected content was introduced by your editor:
7.
   > The \<confluence-home\>/confluence.cfg.xml file needs to be properly formatted. It can be checked using online tools like W3 School XML Validator or advanced editors like IntelliJ or Eclipse. The file might have some hidden characters like "space" in the wrong place (e.g befor the opening \<?xml\>) or some elements might not be closed properly which can break the XML file format.
8. Copy the newly generated confluence.cfg.xml to your Production home directory. Since you don't have a backup of it you may use the newly generated one - it will obviously not have your attachments but should work.
9. Start up the Production Confluence and test.

Similar instructions may be found in [How to Generate a New confluence.cfg.xml](https://confluence.atlassian.com/confkb/how-to-generate-a-new-confluence-cfg-xml-425461512.html)

I look forward to hearing how it goes.

Thanks,

Ann

comments: author: Mark Hylas
body: Hi Ann, thanks for the reply.

These steps seem to have worked, although, I'm not seeing all of the spaces I'd had before. I think another employee started making new ones at some point, but I can still see the old content in tact in the database. Perhaps reindexing will help?


author: Shannon S
body: Hello Mark,

Is the new installation the same version as your previous installation?

If you have a backup of the home directory, you can ensure a more identical instance by following the process at [Restoring Data from other Backups](https://confluence.atlassian.com/doc/restoring-data-from-other-backups-148627.html). This will remove the initial setup step that you did and adds the step of including the Confluence home directory.

Lastly, if your previous installation went awry, there could actually be an issue with your database itself. Are you at least able to connect to the database and see the tables? If you can tell us exactly what happened before, we could help you to recover from that situation.

Regards,

Shannon

comments: author: Mark Hylas
body: Hi Shannon, thanks for your reply.

I do not have a backup of the home directory, just a database. I made the mistake of beginning another installation a few weeks ago so I know I'll be missing attachments and such, and I know restoring the content with a database only will be difficult.

I read the document you linked to; unfortunately, it does not help. For my specific situation, all it suggests is making the connection in the config file, which produces the error I linked to in my original post. I really just want some way to extract my content. I can connect to the database and see the tables. The database is in tact.