How to migrate Bitbucket to AWS

tomisaacson October 31, 2018

I'm incredibly frustrated. I've been trying to migrate our Bitbucket server from a local VM to AWS and I can't get it to work. I started with https://confluence.atlassian.com/bitbucketserver/administering-bitbucket-server-in-aws-776640308.html then used the server template from https://confluence.atlassian.com/bitbucketserver/quick-start-with-bitbucket-server-and-aws-776640254.html. We backed up our existing server using Bitbucket Server Backup Client so I went to https://confluence.atlassian.com/bitbucketserver/using-the-bitbucket-server-backup-client-776640064.html#UsingtheBitbucketServerBackupClient-runrestore.

But here's where I started to have trouble. The server seemed to have a demo project in /var/atlassian/application-data/bitbucket but the additional storage (200GB) appeared under /media/atl/bitbucket/:

$ df -hl
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 80K 1.9G 1% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/xvda1 50G 43G 6.9G 87% /
/dev/xvdb 15G 39M 15G 1% /media/ephemeral0
tank/atlassian-home 193G 66M 193G 1% /media/atl
tank 193G 0 193G 0% /tank

I stopped the server:

sudo -u atlbitbucket /opt/atlassian/bitbucket/bin/stop-bitbucket.sh

then tried using:

sudo -u atlbitbucket /opt/atlassian/bitbucket/bin/set-bitbucket-home.sh /media/atl/bitbucket

I couldn't figure out the parameters for the restore. After some guesswork I took the username and password from /var/atlassian/application-data/bitbucket/shared/bitbucket.properties, then guessed at the database host and port:

sudo java -Djdbc.override=true -Djdbc.driver=org.postgresql.Driver -Djdbc.url=jdbc:postgresql://localhost/bitbucket -Djdbc.user=atlbitbucket -Djdbc.password=#### -Dbitbucket.home=/media/atl/bitbucket/ -jar bitbucket-restore-client.jar bitbucket-20181024-233703-804.tar

But then I got "The target database contains tables whose names collide with Bitbucket's tables. Please migrate to a clean, empty database."

So I used:

sudo -u atlbitbucket psql -d bitbucket -U atlbitbucket

then this code to clear the database https://stackoverflow.com/a/36023359/264822

I finally got the restore to work and I reran the server  but now when I open the URL it redirects to http://127.0.0.1:7990/setup. It's likely that one of my previous steps has screwed something up but I have no idea because of the complete lack of documentation around this.

Does anyone have any experience with this? Once I get the damned thing working I'm going to write up a blog post so nobody else has to go through this stupidity.

 

 

2 answers

1 vote
Emily Chan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 13, 2020

Hi @tomisaacson and Community!

We've just built the beta of a solution to help ease migrations from Server/Data-Center-on-prem to Data-Center-on-AWS-Quickstarts.

Would you be interested to join our beta program and try out this solution? If you're interested, or would like to find out more, please email me at echan@atlassian.com. 

0 votes
John Lawlor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2018

That looks like Bitbucket can't talk to the database, so it's starting up as if it was a fresh install.

Can you check your database connection settings in your bitbucket.properties?

Also check /var/atlassian/application-data/bitbucket/log/atlassian-bitbucket.log to see if there are any connection errors shown there.

tomisaacson November 1, 2018

/media/atl/bitbucket/shared/bitbucket.properties:

jdbc.url=jdbc\:postgresql\://localhost/bitbucket
jdbc.driver=org.postgresql.Driver

I can't see anything that looks like an error in the log, but not sure what I'm looking for.

John Lawlor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2018
jdbc.driver=org.postgresql.Driver
# primary db url
jdbc.url=jdbc:postgresql://localhost:5432/bitbucket

 

Maybe try and add the port number as above..

 

Also, I see that you are using a non-standard install location, as in /media instead of /var. That complicates things slightly. Make sure the shell scipts in /opt/atlassian/bitbucket/5.15.0/bin/ are using the /media path rather than /var.

tomisaacson November 2, 2018

How do I know what the port number is? That's part of my problem, none of this is documented in the setup instructions.

I'm using a non-standard install location because I need more storage in my VM and that's where AWS adds it. How else should I be doing this?

John Lawlor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 5, 2018

The default port is 5432 for postgres. You can confirm that postgres is running on that port with:

netstat -anp | grep 5432

Let's make that change first and go from there.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events