Connecting Bitbucket Server to an external database

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This page provides information about using Bitbucket Server with an external database.

Bitbucket Server 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 Server.

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 Server to the supported external databases:

MySQL is not supported for Bitbucket Data Center instances. MySQL is supported for Bitbucket Server (standalone) instances, but not recommended. See Connecting Bitbucket Server to MySQL for more information.

Why would I want to use an external database?

Bitbucket Server 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 Server 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 Server instance, running the database on the same server as Bitbucket Server may slow it down. We recommend that for large installations, Bitbucket Server 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 Server, which will limit performance.
  • Unified back-up: Use your existing DBMS tools to back up your Bitbucket Server database alongside your organization's other databases.
  • Bitbucket Data Center support: If you want to upgrade your instance to Bitbucket Data Center, either now or in the future, to take advantage of the performance-at-scale and high availability benefits of running Bitbucket Server 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 Server data:

  • from the embedded database to a supported external DBMS.
  • to another instance of the same DBMS.
  • from one DBMS to another supported DBMS (for example, from MySQL to PostgreSQL).

You need to have created the DBMS (such as PostgreSQL) that you wish to migrate the Bitbucket Server data to before running the Migration Wizard.

To run the Database Migration Wizard:

  1. Log in to Bitbucket Server.
  2. In the administration area, click Database (under 'Settings').
  3. 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 Bitbucket Server home directory. If you intend to migrate from one external database to another, you should also backup the existing database before proceeding. See Data recovery and backups for more information.
     
  • Bitbucket Server will be unavailable during the migration:
    Bitbucket Server will not be available to users during the database migration operation. In addition, running the migration when people are using Bitbucket Server can sometimes cause the migration to time out waiting for all activity in Bitbucket Server 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 Server database being migrated. For new installations of Bitbucket Server, containing very little data, the migration process typically takes just a few seconds. If you have been using Bitbucket Server for some time, its database will contain more data, and the migration process will therefore take longer. If Bitbucket Server has been linked to a JIRA Software instance, and there are hundreds of thousands of commits in Bitbucket Server 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 Server database: 
    In case of a migration failure, Bitbucket Server may have partially populated the target database. If the target database is new (therefore empty) and set aside for Bitbucket Server'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 Bitbucket Server 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.
    • Migration will create a dump file of the contents of your database in the Bitbucket Server 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.

Last modified on Sep 21, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.