Bring Your Own Database
In this guide, you'll learn how to bring your own PostgreSQL database instance to DBOS Cloud and deploy your applications to it.
This feature is currently only available to DBOS Pro or Enterprise subscribers.
Linking Your Database to DBOS Cloud
To bring your own PostgreSQL database instance to DBOS Cloud, you must first create a role DBOS Cloud can use to deploy and manage your apps.
This role must be named dbosadmin
and must have the LOGIN
, CREATEDB
and CREATEROLE
privileges:
CREATE ROLE dbosadmin WITH LOGIN CREATEDB CREATEROLE PASSWORD <password>;
Next, link your database instance to DBOS Cloud, entering the password for the dbosadmin
role when prompted.
You must choose a database instance name that is 3 to 16 characters long and contains only lowercase letters, numbers and underscores.
npx dbos-cloud db link <database-instance-name> -H <database-hostname> -p <database-port>
You can now register and deploy applications with this database instance as normal! Check out our applications management guide for details.
DBOS Cloud is currently hosted in AWS us-east-1. For maximum performance, we recommend linking a database instance hosted there.
Enabling Time Travel
DBOS Cloud uses Postgres logical replication to capture database history information used in time travel.
To enable logical replication, you must configure the PostgreSQL wal_level
to logical
and increase max_replication_slots
to ensure your database has at least three open replication slots per DBOS application you intend to deploy:
- AWS RDS PostgreSQL
- PostgreSQL
Create or edit your database instance's parameter group to set:
rds.logical_replication = 1
max_replication_slots = 30 # At least three open replication slots per DBOS application
Edit your postgresql.conf
and add or modify the following lines:
wal_level = logical
max_replication_slots = 30 # At least three open replication slots per DBOS application
Additionally, you must install the wal2json PostgreSQL extension. Follow this installation guide to enable it for your database.
You need to restart your database after changing these parameters for the changes to take effect.
Additionally, you must grant the dbosadmin
role permissions to manage replication slots and subscriptions:
- AWS RDS PostgreSQL
- PostgreSQL
CREATE ROLE dbosadmin WITH LOGIN CREATEDB CREATEROLE PASSWORD <password>;
GRANT rds_replication to dbosadmin;
GRANT pg_create_subscription TO dbosadmin;
CREATE ROLE dbosadmin WITH LOGIN CREATEDB CREATEROLE REPLICATION PASSWORD <password>;
GRANT pg_create_subscription TO dbosadmin;
The pg_create_subscription
role is added in PostgreSQL version 16. For earlier PostgreSQL versions, you may grant dbosadmin
a superuser role or contact us for help.
Finally, link your database instance to DBOS Cloud with time travel enabled, entering the password for the dbosadmin
role when prompted:
npx dbos-cloud db link <database-instance-name> -H <database-hostname> -p <database-port> --enable-timetravel
You can now register and deploy applications with this database instance as normal and make full use of time travel! Check out our applications management and time travel guides for details.