> ## Documentation Index
> Fetch the complete documentation index at: https://uncoded.ch/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Database migration

> How to back up and migrate your unCoded database when upgrading to a newer version.

When you upgrade unCoded to a newer version, you may need to migrate your existing database to the new bot instance. This guide walks you through the full process using DBeaver, a free database management tool.

<Warning>
  Always back up your database before performing a migration or installing a new version. Skipping the backup step risks permanent data loss if the migration encounters an error.
</Warning>

<Note>
  If you already know how to use DBeaver, you can skip to [Restore the database to the new bot](#restore-the-database-to-the-new-bot).
</Note>

***

## Step 1: Verify server configuration

Make sure you have the latest Linux version installed on your server, including CapRover integration. If not, follow the [server setup guide](/getting-started/start-your-server) before continuing.

***

## Step 2: Create a new unCoded bot instance

Create a new trading bot in unCoded following the [bot creation instructions](/getting-started/start-your-server). Ensure you are signed in with your Google account and that your Binance UID is linked.

***

## Step 3: Prepare DBeaver

<Steps>
  <Step title="Download and install DBeaver">
    Download DBeaver from [dbeaver.io/download](https://dbeaver.io/download) and install it on your device. Other database tools work too, but this guide is based on DBeaver.
  </Step>

  <Step title="Open the database port">
    In CapRover, open your bot's database app — named **YOUR-BOT-NAME-db**. Navigate to **App Configuration** and add a port mapping, setting both fields to `5432`. Click **Save & Restart** to apply.
  </Step>
</Steps>

***

## Step 4: Connect DBeaver and back up your data

<Steps>
  <Step title="Create a new database connection">
    Open DBeaver and click **New Database Connection** in the top left corner.
  </Step>

  <Step title="Select PostgreSQL">
    Choose **PostgreSQL** and click **Next**.
  </Step>

  <Step title="Enter connection details">
    Fill in the following fields:

    | Field                     | Value                                  |
    | ------------------------- | -------------------------------------- |
    | Host                      | Your server IP address                 |
    | Port                      | `5432`                                 |
    | Authentication → Password | Your `POSTGRES_PASSWORD` from CapRover |

    Click **Finish**.
  </Step>

  <Step title="Connect to the server">
    Your server appears in the left sidebar. Select it and click **Connect**. A green checkmark confirms a successful connection.
  </Step>

  <Step title="Open uncoded_db">
    Open the database named `uncoded_db`. If it does not appear, right-click your connection, select **Edit Connection**, enable **Show all databases**, click **OK**, and reconnect.
  </Step>

  <Step title="Back up the database">
    Right-click `uncoded_db` and select **Tools → Global Backup**. Select the database, click **Next**, choose an output folder, name the backup file, and click **Start**. The backup is saved to your device.
  </Step>
</Steps>

***

## Step 5: Restore the database to the new bot

<Steps>
  <Step title="Connect the new bot to DBeaver">
    Repeat the DBeaver connection steps (Step 4) for your new bot instance to establish a connection to the new database.
  </Step>

  <Step title="Restore from backup">
    Right-click the `uncoded_db` database in the new connection, select **Tools → Restore**, enable **Clean Database**, select your backup file, and click **Start**.
  </Step>

  <Step title="Restart the bot">
    Once the restore completes, restart your unCoded trading bot in CapRover. The migration is complete.
  </Step>
</Steps>

***

## When migration is required

Not every update requires a database migration. Check the release notes or the unCoded Telegram community for version-specific instructions. Migration is typically required when upgrading between major versions.

For questions about a specific version upgrade, reach out via the [support and contact page](/support/contact).
