# Manage multi-instance deployment

UI Bakery supports multi-instance deployment and synchronization.&#x20;

**Key considerations include:**

* Apps must be connected to a Git repository and synchronized through it.
* Data sources and roles used in the apps need to be manually synchronized.

This guide describes the deployment of two UI Bakery instances in your setup, but it is also applicable to multiple instances.

## Data Sources consistency across instances

To synchronize your app and import it into another instance, you need to ensure that the new instance has an identical list of data sources **with the same data source IDs as the original instance**.&#x20;

To do so, follow the steps below:

*In the Original Instance:*

1. Open the *settings* of the **Data source** you want to synchronize.
2. Copy the **data source ID** next to the **Data Source name**.

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

*In the Second Instance:*

1. Start connecting a new data source, entering its name and other required details.
2. Click on the **ID** field next to the **Data Source name** to make it editable.
3. Paste the data source ID copied from the first instance and click **Connect Datasource**.

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

{% hint style="warning" %}
Data source ID can only be specified **during the creation of the data source**.

If you have existing data sources with different IDs, consider deleting them and creating new ones from scratch. Once the ID is correctly specified, the app will automatically start working with the new data source.
{% endhint %}

## **Roles consistency across instances**

When using roles to manage page visibility, it is crucial to maintain **identical role IDs across all instances.**&#x20;

Follow the steps below for effective roles synchronization:

*In the Original Instance:*

1. Open the **settings** of the role you want to synchronize.
2. Copy **role ID** in the upper right corner.

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

*In the Second Instance:*

1. Navigate to **Users & Permissions**, switch to the *Roles* tab and click **Add Custom Role**.
2. Enter role name and set its permissions.
3. Click on the **ID** field in the upper right corner to make it editable.
4. Paste the role ID copied from the first instance.
5. Finally, click **Create role**.

{% hint style="info" %}
Contrary to data sources, **role** **IDs can be modified for existing roles**. This allows assigning custom IDs to built-in roles like Admin, User, and Editor.

However, caution is advised when editing role IDs. Incorrect modifications can lead to pages not displayed properly within the app. *It is generally recommended to avoid altering role IDs unless absolutely necessary.*
{% endhint %}

## Import an app from a Git repository

Once you have manually synchronized data sources and roles, you can proceed to importing your app using Git.&#x20;

To do so, follow the steps below:

1. Upon app creation, choose the *Import from Git* option in the **Create new** menu.
2. Enter the **Git repository URL**.
3. Next, copy the *SSH key* suggested by UI Bakery and create a new key in the **Deploy keys** settings of your Git provider. \
   For GitHub, follow the steps below:
   1. Open your repository settings and open the **Deploy keys** tab.
   2. Here, click **Add deploy key** and paste the SSH key you've copied before.
   3. Select the **Allow write** **access** checkbox and then click **Add key**.
4. Next, go back to UI Bakery and click **Import app**.

Now the app is connected to the Git repository and can be pulled and deployed when new changes are available.

## Keep data sources and user roles in sync when adding new ones

When developing a new feature, make sure to follow these [guidelines](/concepts/source-control.md#making-changes-to-the-app).&#x20;

Once the feature is deployed on the current instance and ready to be rolled out to another instance, pull the changes from the Git repository. If new user roles or data sources have been added to your instance, ensure they are in sync across all instances.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/on-premise/git-source-control/managing-multi-instance-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
