Connect Bitbucket to an external database
This page provides information about using Bitbucket Data Center with an external database.
Bitbucket ships with an embedded database that it uses straight out-of-the-box, with no configuration required. This is great for evaluation purposes, but for production installations, we recommend that you use one of the supported external databases.
Please refer to Supported platforms for the versions of external databases supported by Bitbucket.
If you just want to change the password for the external database, see How do I change the external database password.
Instructions for connecting Bitbucket to the supported external databases:
Why would I want to use an external database?
Bitbucket ships with an embedded database that is great for evaluation purposes, but for production installations we recommend that you make use of one of the supported external databases, for the following reasons:
- Improved protection against data loss: The Bitbucket Data Center built-in database, which runs HSQLDB, is susceptible to data loss during system crashes. External databases are generally more resistant to data loss during a system crash. HSQLDB is not supported in production environments and should only be used for evaluation purposes.
- Performance and scalability: If you have a large number of users on your Bitbucket instance, running the database on the same server as Bitbucket may slow it down. We recommend that for large installations, Bitbucket and the DBMS are run on separate machines. When using the embedded database, the database will always be hosted and run on the same server as Bitbucket, which will limit performance.
- Unified back-up: Use your existing DBMS tools to back up your Bitbucket database alongside your organization's other databases.
- Bitbucket Data Center support: If you want to upgrade your instance to Bitbucket Data Center resources, either now or in the future, to take advantage of the performance-at-scale and high availability benefits of running Bitbucket Data Center in clustered mode, then you must use an external database. HSQLDB is not supported in Bitbucket Data Center.
Using the Database Migration Wizard
The Database Migration Wizard is not supported in Bitbucket Data Center instances while more than one cluster node is running. To migrate databases for a Bitbucket Data Center instance, you should perform the migration before starting multiple cluster nodes.
You can use the Database Migration Wizard to migrate the Bitbucket data:
- from the embedded database to a supported external DBMS.
- to another instance of the same DBMS.
- from one DBMS to another supported DBMS.
You need to have created the DBMS (such as PostgreSQL) that you wish to migrate the Bitbucket data to before running the Migration Wizard.
To run the Database Migration Wizard:
- Log in to Bitbucket.
- In the administration area, click Database (under 'Settings').
- Click Migrate database and follow the instructions for running the migration.
Notes about database migration
- Back up the database and Bitbucket home directory:
Before starting the database migration process you should back up your Set the home directory. If you intend to migrate from one external database to another, you should also back up the existing database before proceeding. See Data recovery and backups for more information.
- Bitbucket will be unavailable during the migration:
Bitbucket will not be available to users during the database migration operation. In addition, running the migration when people are using Bitbucket can sometimes cause the migration to time out waiting for all activity in Bitbucket that uses the database to complete. For these reasons, we recommend that you run the database migration outside of normal usage periods.
- Migration will usually take less than 30 minutes:
The duration of the migration process depends on the amount of data in the Bitbucket database being migrated. For new installations, containing very little data, the migration process typically takes just a few seconds. If you have been using Bitbucket for some time, its database will contain more data, and the migration process will therefore take longer. If Bitbucket has been linked to a JIRA Software instance, and there are hundreds of thousands of commits in Bitbucket with issue keys in the commit messages, the migration may take tens of minutes.
- We strongly recommend using a new clean database for the new Bitbucket database:
In case of a migration failure, Bitbucket may have partially populated the target database. If the target database is new (therefore empty) and set aside for Bitbucket's exclusive use, it's very easy to clean up after a failed migration; just drop the target database and use a clean target database instance for the next attempt.
- Ensure your Set the home directory is secured against unauthorized access:
- After the migration, the connection details (including the username and password) for the database are stored in the
bitbucket.properties
file. - The migration will create a dump file of the contents of your database in the Bitbucket home
export
directory. This is used during the migration and is kept for diagnostic purposes in the case of an error. You may remove this after migration but it may reduce Atlassian Support's ability to help you in the case of migration issues. You can edit the database password if needed after migration.
- After the migration, the connection details (including the username and password) for the database are stored in the