Confluence test environment replica from production
Asked by vivuu:

We are in process to replicate confluence prod which is running behind a reverse proxy to another test server with same configuration should be reflect here.

version 5.10.0, windows 2012, MSSQL DB.

steps followed.

1) installed confluence same version in new windows server (didnt complete the setup as it is asking new db creation but we want to map to existing db)

2) Db backup taken from PROD DB and restored in Test DB server

3) replaced the newly installed confluence home directory with copied production home directory.

4) made the db information changes in confluence.config file

5) started the confluence service, but getting below error.

"Spring Application context has not been set"

tried all troubleshooting steps given in sites as permission part and everything but still same issue


Answers:
author: Davin Studer
body: These are the steps I take when I refresh our non-prod environment and they haven't failed me yet.

```
1. Make sure World Wide Web Publishing Service is stopped.
2. Uninstall Confluence from the non-prod server.
3. Remove Atlassian folder. C:\Program Files\Atlassian
4. Delete the Confluence database on non-prod
5. Create a new database called Confluence and make the confluence database user a db_owner.
6. Run these two SQL statements against it
    a. ALTER DATABASE Confluence COLLATE SQL_Latin1_General_CP1_CS_AS
    b. ALTER DATABASE Confluence SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE
7. Install the same version of Confluence as is currently in prod to the non-prod server.
8. Launch the site in a browser.
9. Install a Production installation
10. Visit my.atlassian.com to get a developers license for Confluence.
11. Put the license into the web page
12. Select Microsoft SQL Server as the External Database
13. Enter your databse credentials
14. Set user management to Manage users and groups within Confluence
15. Install using a blank or demo site. It doesn't matter.
16. Finish the Confluence setup.
17. Stop the Atlassian Confluence service on the non production server.
18. Take a backup of the production Confluence database.
19. Delete the Confluence database on the non production server.
20. Restore the backup of prod to the non production server.
21. Make sure after the restore that the DB owner is sa.
22. Zip the Confluence home directory on the production server. (C:\Program Files\Atlassian\Application Data\Confluence)
23. Copy the zip file from the production server to the non production server.
24. Unzip the file and move all of the contents except the index folder, temp folder, logs folder, the confluence.cfg.xml, and the file called "lock" to the C:\Program Files\Atlassian\Application Data\Confluence folder on the non production server.
25. Delete the index folder on the non production server and then create a new folder called index.
26. Move the edge and plugin folders from the production index folder to the non production index folder that you just created.
27. Run these two sql statements against the non-production database
    a. delete from Confluence.dbo.BANDANA where BANDANAKEY = 'atlassian.confluence.smtp.mail.accounts'
    b. delete from Confluence.dbo.BANDANA where BANDANAKEY = 'atlassian.confluence.space.mailaccounts'
28. Apply any changes made to prod files. Examples below ...
    a. Database connections in C:\Program Files\Atlassian\Confluence\conf\server.xml
    b. Service startup parameters
    c. SSL reverse proxy setup in C:\Program Files\Atlassian\Confluence\conf\server.xml
    d. Importing Domain Controller cert chain into C:\Program Files\Atlassian\Confluence\jre\lib\security\cacerts for LDAPS
    e. Custom changes made to C:\Program Files\Atlassian\Application Data\Confluence\confluence.cfg.xml
29. Restart the Atlassian Confluence service.
30. Set the Server Base Url in Confluence Admin -> General Configuration.
31. Go to Confluence Admin -> Administration -> Content Indexing and rebuild the index.
```

comments: author: vivuu
body: Hi Davin,

Thanks the steps are well clear. But here we are stuck with the restored DB.

We havent created a fresh Db and completed the installation in non-prod. we just installed confluence and tried to map to the restored DB my making change in the confluence config.xml file.

Here we are stuck because we dont have Db access to again create and restore the Db as its handling by some other team.

Do we have any solution the way which we followed. ?


author: Davin Studer
body: No, you need to install with a fresh database and complete the install.

<br />

One thing to note on Microsoft SQL server is that just because you may have SQL logins on prod and non prod with the same user name it will not automatically map up to the restored database because the SID (backend SQL Server user identifier) will be different between the two servers. So, the DBA will need to remove the Confluence database user from the restored database and then add the user from the non prod system to the restored database as a db_owner. Also, make sure that the database connection is correct in the confluence.cfg.xml for these keys ...

* hibernate.connection.password
* hibernate.connection.url
* hibernate.connection.username


author: vivuu
body: We have migrated all our applications, Crowd, Jira, Bitbucket, Confluence to Test environment from Prod Servers.(By application data and DB data store to Test environment)

<br />

But , The application integration to Test Crowd and between Test applications how can make to Test Configuration for these applications, without affecting PROD

1)Test Crowd Should authenticate all test environemnt applications (Currently test crowd containing map with Prod application IP Addresses)

2)How The integration Between These applications in test environment can be replaced to Test application integration by removing PROD links

Since Production Data are copied and DB are restored, Now the test applications will be having old trace with the production instances. How to revert it with test instances and what are the files need to be edited for enabling the integration


author: vivuu
body: Now Our Prod setup-Crowd-2.11.1 in Windows server and it should be migrated to linux machine in another domain with a different url .  
currently in windows the atlassin application are running behind reverse proxy and for authentication we are using crowd internal directory ?

So please let us know what are the steps need to be implemented for data migration to new instance in the linux (windows to linux )

using MSSQl DB in both environment


author: Brant Schroeder
body: I would redo the installation as it sounds like a permission issue. This time when you do the installation attach it to a DB and let it complete. I would ensure that confluence starts. Then stop the service restore your DB to the newly created DB and copy over the confluence home directory and update your config file. If everything was working and stops after you copy everything over I would look at the confluence home directory permissions that might be migrating with the windows files. I would ensure that the the proper permissions have been applied to the home directory files for confluence to run.

comments: author: vivuu
body: HI Brant,

Thanks for your quick reply.

But here we have some issues here.

The infra team here restored the DB to new server as per our suggestion, as we thought we can directly restore and point the new confluence to the restored DB. So are you telling like there is no posibility to do that ? (create one db and drop that then restore Db will be a hectic work for them if we ask and it is handling by another team). I hope there will be other posibilities to do without creating a fresh DB and restoring it. Eg: If DB server got crashed, we have to go for a restore from the backup and there what can we do.

Please suggest us your valuable comment.


author: vivuu
body: content Deleted


author: Davin Studer
body: You should not post your config file above. It contains you license key and username and password. If you cannot delete it let me know and I'll delete it for you.


author: Nic Brough -Adaptavist-
body: I'm afraid you need to do what Brant said.

If you want to "point a new Confluence at a copy of a database", you should install the new Confluence in full first, not get halfway through and stop. Get it to a point where you can log into an empty Confluence.

Then stop it, load the database, and copy over the data portions of the home directory (NOT all of it - you need attachments and plugins. Taking the rest will destroy your config), restart the new Confluence and kick off a global re-index.


author: vivuu
body: Ok. Then we will go for the way which you suggested.

But here one more doubt that, while we are going for fresh setup of the DB for the new confluence instance, should the name of the DB should exactly same as the Prod DB which we are going to replace.?


author: Nic Brough -Adaptavist-
body: It can be, as long as it's empty when you do the initial setup. If you connect a new setup to an existing database, it will fail because the tables are already there.


author: vivuu
body: So here, we have to drop the current restored production db and have to create a fresh DB with the same name in testing Db server, then complete the confluence installation,

Once its done,

we can delete the fresh DB in in test sql server and again restore with prod db

then map the confluence instance with restored DB ?


author: Davin Studer
body: You don't need to drop the restored one. Just create a fresh database with a different name and do the install to the new database name. After the install is complete edit the confluence.cfg.xml to point to the restored prod db. Then you can drop the one created for the install.


author: vivuu
body: We have migrated our PROD setup of Confluence to Test environment and its working fine as expected. Here the data of Application directory and SQL DB were taken and restored are 30 days before.

<br />

Now we have to make the Test Confluence data to be updated till the date of today in PROD. How we can achieve this?

Please share us the all the possible ways.

comments: author: Nic Brough -Adaptavist-
body: See <https://community.atlassian.com/t5/Confluence-questions/Update-Test-Confluence-with-Delta-change-till-today/qaq-p/675433>


author: vivuu
body: We have migrated all our applications, Crowd, Jira, Bitbucket, Confluence to Test environment from Prod Servers.(By application data and DB data store to Test environment)

<br />

But , The application integration to Test Crowd and between Test applications how can make to Test Configuration for these applications, without affecting PROD

1)Test Crowd Should authenticate all test environemnt applications (Currently test crowd containing map with Prod application IP Addresses)

2)How The integration Between These applications in test environment can be replaced to Test application integration by removing PROD links

Since Production Data are copied and DB are restored, Now te test applications will be having old trace with the production instances. How to revert it with test instances and what are the files need to be editedd for enabling the integration