> ## 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 Upgrade & Migration

How to migrate your data from an older version and move your database to a different server.

***

# Upgrade your unCoded version

How to migrate an older bot database to the latest version. Step-by-step guide to migrating an older bot database to the latest version. Learn how to safely migrate an older bot database to the newest version.

<Note>
  Before performing any new installation, make sure to back up your old database first. See **Step 4**.

  If you already know how to use DBeaver, jump to: **Restore the old database to the new bot.**
</Note>

<Steps>
  <Step title="🖥️ Server configuration" titleSize="h2">
    Make sure you have already installed the latest Linux version, including CapRover integration, on your server.

    If not, please follow the correct setup guide here: [Setup your Server](/netcup-server-setup).

    ***
  </Step>

  <Step title="🤖 Create an unCoded bot" titleSize="h2">
    Create a new trading bot in unCoded. You can find the detailed instructions here: [**Create your unCoded Bot**](/netcup-server-setup).

    <Note>
      Make sure you are signed in to the website with your Google account.

      Also make sure that you have added your [Binance UID / Binance API](/backup-set-up).
    </Note>

    ***
  </Step>

  <Step title="🗂️ Prepare your Database" titleSize="h2">
    This guide is based on DBeaver, but other database tools can be used as well.

    [Download](https://dbeaver.io/download/) the software to your device and install it.

    ### Open the database port for DBeaver (Netcup / Caprover)

    <Warning>
      This Section is for your Netcup / Caprover Setup. Scroll down to the [next section](#prepare-your-railway-instance) to learn how to prepare your Railway / Zeabur setup.
    </Warning>

    Before downloading the database, you need to expose a port for DBeaver first.

    In your bot, open **“YOUR-BOT-NAME-db”.**

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(13).png" alt="Image (13)" />
    </Frame>

    * Then navigate to **“App Configuration”** and add a **Port mapping**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(14).png" alt="Image (14)" />
    </Frame>

    * Set both fields to **"5432"**.

    * Click **Save & Restart** to apply the changes.

    ## Prepare your Railway Instance

    <Warning>
      Learn how to prepare your Railway instance for your database connection.
    </Warning>

    <iframe src="https://www.youtube.com/embed/oiEttMKL74U" title="YouTube video player" frameborder="0" className="w-full aspect-video rounded-xl" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

    ## Prepare your Zeabur Instance

    <Warning>
      Learn how to prepare your Zeabur instance for your database connection.
    </Warning>

    To connect DBeaver to your Zeabur database, you do not need to configure or enable anything manually. To establish the connection, we simply need to locate the correct database values in Zeabur and enter them into DBeaver.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(11).png" alt="Image (11)" />
    </Frame>

    * To get the required values, first open your project folder in the [Zeabur dashboard](https://zeabur.com/projects).

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(38).png" alt="Image (38)" />
    </Frame>

    * Under the **Overview** section, you will need the **PostgreSQL Password**. Save this value for later.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(39).png" alt="Image (39)" />
    </Frame>

    * Then switch to the **Networking** section.
    * There, copy the **domain/IP** and the corresponding **port**.
          <Note>
            You will learn how to use these details in DBeaver in the following section.
          </Note>

    ***
  </Step>

  <Step title="🛜 Connect DBeaver to your database and Backup your Data" titleSize="h2">
    Now connect your database to DBeaver to gain access.

    Open **DBeaver** and click **“New Database Connection”** in the top left corner.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(15).png" alt="Image (15)" />
    </Frame>

    * Select \*\*"PostgreSQL"\*\*and click **“Next”**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(16).png" alt="Image (16)" />
    </Frame>

    * Then enter the following details:
      * ​**Host:** Your server IP
      * ​**Port:** `5432`
      * ​**Authentication → Password:** Your `POSTGRES_PASSWORD` from CapRover
    * Click **“Finish”**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(17).png" alt="Image (17)" />
    </Frame>

    * Your server should now appear in the **left sidebar**. Select it and click **“Connect”** in the top left corner. If the connection is successful, a green checkmark will appear and you will be able to open the database.
    * Open the database named `uncoded_db`.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(18).png" alt="Image (18)" />
    </Frame>

    * If it does not appear, right-click your server connection and select **“Edit Connection”**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(19).png" alt="Image (19)" />
    </Frame>

    * Then enable **“Show all databases” and press "OK"**. Reconnect your Database.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(20).png" alt="Image (20)" />
    </Frame>

    * After that, `uncoded_db` should be visible.

    * Right-click the database and select **Tools → Global Backup**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(21).png" alt="Image (21)" />
    </Frame>

    * Choose the database and click **“Next”**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(22).png" alt="Image (22)" />
    </Frame>

    * Under **“Output folder”**, select the location where the backup should be saved and give the backup file any name you want.
    * Then click **“Start”**. Your database will now be backed up to your device.
    *

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(23).png" alt="Image (23)" />
    </Frame>

    **Repeat the database connection steps for the new app so you can restore the backup there.**

    ***
  </Step>

  <Step title="⚙️ Restore the old database to the new bot" titleSize="h2">
    Once you have successfully connected the **<u>new</u>** bot / server to DBeaver, right-click the `uncoded_db` database you want to replace, then select **Tools → Restore**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(24).png" alt="Image (24)" />
    </Frame>

    * Enable **"Clean Database"**, then select the backup file from your computer. After that, click **"Start"**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/arrowtradeag/images/image-(25).png" alt="Image (25)" />
    </Frame>

    Once the restore is complete, restart your **unCoded trading bot in your Caprover App**. The migration is now finished.

    <Note>
      **HAPPY TRADING!**
    </Note>
  </Step>
</Steps>
