How to restore a deleted connection

This tutorial shows how to restore a deleted connection in your Airbyte instance.
It was tested in version 0.40.26 of Airbyte maybe in the future it can change this process.

Here is my connection example

I will delete it to show you how to restore after.
Accessing the connection will show it was deleted :frowning:

Reactive the connection

Airbyte actually doesn’t delete the connection, it will disable in the internal database. Precisely because of these situations.

First get the connection id for the deleted connection.


In my case my connection id is: 1cde4e25-e60e-4fed-804d-70ef74a9b1e5 the image above helps you to find yours. Also I’m going to show querying the database to find previous deleted connections you don’t have access right now.

Let’s access the Airbyte database to reactive our connection.
docker exec -ti airbyte-db psql -U docker airbyte to access it.
In psql console run:

select id, name, created_at, updated_at, status from connection where status='deprecated';

The output for me is:

airbyte=# select id, name, created_at, updated_at, status from connection where status='deprecated';
                  id                  |        name        |          created_at           |          updated_at          |   status
--------------------------------------+--------------------+-------------------------------+------------------------------+------------
 1cde4e25-e60e-4fed-804d-70ef74a9b1e5 | Example Connection | 2022-12-22 16:48:53.469349+00 | 2022-12-22 16:57:51.06029+00 | deprecated
(1 row)

Now we must change the status from deprecated to active. Airbyte connections have 3 types of status: active, inactive, deprecated.

Run the command to restore the connection:
update connection set status='active' where id='1cde4e25-e60e-4fed-804d-70ef74a9b1e5';

The output should be something:

UPDATE 1

If you return to your Airbyte UI you will see the deleted connection again!
The problem is if you try to trigger the sync it won’t work!

The reason is because the workflow in temporal was deleted :frowning:
Let’s recreate it!

Recreate Temporal Workflow

Access the temporal docker container
docker exec -ti airbyte-temporal bash

You must configure some variables to make the tctl temporal cli to work.

  1. hostname -i copy the output
  2. export TEMPORAL_CLI_ADDRESS=<the value from previous command>: 7233 in my case is something export TEMPORAL_CLI_ADDRESS=172.19.0.8:7233
  3. run env | grep TEMPORAL confirm you see the new env variable

Edit the command below:

tctl workflow start \
  --workflow_id connection_manager_<CONNECTION_ID> \
  --taskqueue CONNECTION_UPDATER \
  --workflow_type ConnectionManagerWorkflow \
  --execution_timeout 100000000 \
  --workflow_task_timeout 100000000 \
  --input '{
      "connectionId": "<CONNECTION_ID>",
      "jobId": null,
      "attemptId": null,
      "fromFailure": false,
      "attemptNumber": 1,
      "workflowState": null,
      "resetConnection": false
    }'

For me is

tctl workflow start \
  --workflow_id connection_manager_1cde4e25-e60e-4fed-804d-70ef74a9b1e5 \
  --taskqueue CONNECTION_UPDATER \
  --workflow_type ConnectionManagerWorkflow \
  --execution_timeout 100000000 \
  --workflow_task_timeout 100000000 \
  --input '{
      "connectionId": "1cde4e25-e60e-4fed-804d-70ef74a9b1e5",
      "jobId": null,
      "attemptId": null,
      "fromFailure": false,
      "attemptNumber": 1,
      "workflowState": null,
      "resetConnection": false
    }'

Copy the command and run in your terminal and you should see the output:

Started Workflow Id: connection_manager_1cde4e25-e60e-4fed-804d-70ef74a9b1e5, run Id: a659c1f6-b94d-426d-a697-96761294702d

Return to your Airbyte UI, refresh it and now you can trigger the sync again