> For the complete documentation index, see [llms.txt](https://docs.uncoded.ch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uncoded.ch/optional-settings/database-upgrade-and-migration.md).

# Database Upgrade & Migration

## 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.

{% hint style="info" %}
Before performing any new installation, make sure to back up your old database first. [<mark style="color:$warning;">See</mark> <mark style="color:$warning;"></mark><mark style="color:$warning;">**Step 4**</mark>](#connect-dbeaver-to-your-database-and-backup-your-data).

If you already know how to use DBeaver, jump to: [<mark style="color:$warning;">**Restore the old database to the new bot**</mark>](#restore-the-old-database-to-the-new-bot)<mark style="color:$warning;">**.**</mark>
{% endhint %}

{% stepper %}
{% step %}

## 🖥️ Server configuration

Make sure you have already installed the latest Linux version, including CapRover integration, on your server.&#x20;

If not, please follow the correct setup guide here: [Setup your Server](/start-your-trading-bot/3.-start-your-uncoded-server.md).

***

{% endstep %}

{% step %}

## 🤖 Create an unCoded bot

Create a new trading bot in unCoded. You can find the detailed instructions here: [**Create your unCoded Bot**](/start-your-trading-bot/3.-start-your-uncoded-server.md#step-3-install-the-uncoded-app).

{% hint style="info" %} <mark style="color:$info;">Make sure you are signed in to the</mark> [<mark style="color:$warning;">website</mark>](https://uncoded.ch/?id=118020526630922890696) <mark style="color:$info;">with your Google account.</mark>

<mark style="color:$info;">Also make sure that you have</mark> [<mark style="color:$warning;">added your Binance UID</mark>](/start-your-trading-bot/1.-set-up-binance-for-uncoded.md)<mark style="color:$info;">.</mark>
{% endhint %}

***

{% endstep %}

{% step %}

## 🗂️ Prepare your Database

This guide is based on DBeaver, but other database tools can be used as well.

[<mark style="color:$warning;">Download</mark>](https://dbeaver.io/download/) the software to your device and install it.

#### Open the database port for DBeaver

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

In your bot, open **“**<mark style="color:purple;">**YOUR-BOT-NAME-db**</mark>**”.**

<figure><img src="/files/YURFcuS14BSAzC0iWgXF" alt=""><figcaption></figcaption></figure>

&#x20;Then navigate to **“**<mark style="color:purple;">**App Configuration**</mark>**”** and add a <mark style="color:purple;">**Port mapping**</mark>.

<figure><img src="/files/0BipFTuDUqrnoA3kdcqs" alt=""><figcaption></figcaption></figure>

Set both fields to "<mark style="color:purple;">**5432"**</mark>.

Click <mark style="color:purple;">**Save & Restart**</mark> to apply the changes.

***

{% endstep %}

{% step %}

### 🛜 Connect DBeaver to your database and Backup your Data

Now connect your database to DBeaver to gain access.

Open **DBeaver** and click **“**<mark style="color:purple;">**New Database Connection**</mark>**”** in the top left corner.

<figure><img src="/files/DwLdFpHK18I66cJBaFYp" alt=""><figcaption></figcaption></figure>

Select **"**<mark style="color:purple;">**PostgreSQL**</mark>**"**&#x61;nd click **“**<mark style="color:purple;">**Next**</mark>**”**.

<figure><img src="/files/bs3YTA76Z7gCI0b3lYx2" alt=""><figcaption></figcaption></figure>

Then enter the following details:

* **Host:** Your server IP
* **Port:** `5432`
* **Authentication → Password:** Your `POSTGRES_PASSWORD` from CapRover

Click **“**<mark style="color:purple;">**Finish**</mark>**”**.

<figure><img src="/files/TAw0M4RiTvoWfViLUhxX" alt=""><figcaption></figcaption></figure>

Your server should now appear in the **left sidebar**. Select it and click **“**<mark style="color:purple;">**Connect**</mark>**”** 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`**.

<figure><img src="/files/lvexaWf8QVHAChh2SOjl" alt=""><figcaption></figcaption></figure>

If it does not appear, right-click your server connection and select **“**<mark style="color:purple;">**Edit Connection**</mark>**”**.&#x20;

<figure><img src="/files/hQ9s0TNEXymNiz8hCsnr" alt=""><figcaption></figcaption></figure>

Then enable **“**<mark style="color:purple;">**Show all databases**</mark>**” and press "**<mark style="color:purple;">**OK**</mark>**"**. Reconnect your Database.&#x20;

<figure><img src="/files/yzBYTYur1Y0H962ZdMIe" alt=""><figcaption></figcaption></figure>

After that, **`uncoded_db`** should be visible.

Right-click the database and select <mark style="color:purple;">**Tools**</mark>**&#x20;→&#x20;**<mark style="color:purple;">**Global Backup**</mark>.

<figure><img src="/files/3jez7ySVmoQicjjoPlOR" alt=""><figcaption></figcaption></figure>

Choose the database and click **“**<mark style="color:purple;">**Next**</mark>**”**.

<figure><img src="/files/DjtaEg1YHvJsgMXAAIFK" alt=""><figcaption></figcaption></figure>

Under **“Output folder”**, select the location where the backup should be saved and give the backup file any name you want.

Then click **“**<mark style="color:purple;">**Start**</mark>**”**. Your database will now be backed up to your device.

<figure><img src="/files/7a1po9FVcTbCZwsYHizQ" alt=""><figcaption></figcaption></figure>

[<mark style="color:$danger;">**Repeat the database connection steps for the new app so you can restore the backup there.**</mark>](#connect-dbeaver-to-your-database-and-backup-your-data)

***

{% endstep %}

{% step %}

## ⚙️ Restore the old database to the new bot

Once you have successfully connected the **new** bot to DBeaver, right-click the **`uncoded_db`** database you want to replace, then select <mark style="color:purple;">**Tools**</mark>**&#x20;→&#x20;**<mark style="color:purple;">**Restore**</mark>.

<figure><img src="/files/Vj33TzmmQ08iDV5HB5e4" alt=""><figcaption></figcaption></figure>

Enable **"**<mark style="color:purple;">**Clean Database**</mark>**"**, then select the backup file from your computer. After that, click **"**<mark style="color:purple;">**Start**</mark>**"**.

<figure><img src="/files/mBcY7DxyCFjwPvQzSGIS" alt=""><figcaption></figcaption></figure>

Once the restore is complete, restart your <mark style="color:purple;">**unCoded trading bot**</mark>**&#x20;in your Caprover App**. The migration is now finished.
{% endstep %}
{% endstepper %}

{% hint style="info" %} <mark style="color:$warning;">HAPPY TRADING!</mark>
{% endhint %}
