Skip to main content

Configure and migrate to an external database

Learn how to store and migrate user information for Self-hosted Retool deployments.

For non-production and development purposes, the default docker-compose configuration for Self-hosted Retool includes a PostgreSQL container and does not set up SSL. This is not suitable for production use cases and you must host the Retool storage database on an external, managed PostgreSQL database. Managed databases are more maintainable, scalable, and reliable than containerized PostgreSQL instances.

If you originally deployed an instance using the default PostgreSQL container, you can migrate its data to an external PostgreSQL database before using the instance in production.

Prerequisites

Before migrating, ensure that your architecture meets the following recommendations and requirements:

  • The minimum recommended version for the PostgreSQL database is version 13. Your PostgreSQL database must also enable the uuid-ossp module and use the Read Committed isolation level.
  • Retool recommends allocating at least 60GB of storage when you set up a new Retool instance. If you're migrating an existing instance, you might need more space.
  • The Retool PostgreSQL database user must have superuser privileges on the hammerhead_production database. This is necessary to perform essential tasks, such as installing updates.

Self-hosted Retool requires the use of an externalized PostgreSQL database (version 13 or later) to manage deployment functions and support stateless deployments. When configuring an external database, you must:

Retool creates a number of tables in the database, such as:

TableDescription
app_observability_provider_configsObservability setup and streaming details.
audit_trail_eventsEvents that feed audit logs on user instances with the /audit endpoint.
grid_managed_cluster_resourcesRetool Database when linked to an external PostgreSQL database.
grid_managed_clustersRetool Database when linked to an external PostgreSQL database.
organizationsSpaces within the organization.
page_savesChanges made to specific apps since they were created.
resourcesResources, including full setup and configuration information.
usersAll enabled and disabled users.
user_task_instanceWorkflows that include user task blocks.

Do not directly modify Retool table data. Doing so can damage the instance.

All storage database tables
access_control_list_members
access_control_lists
access_levels
api_keys
app_metadata
app_themes
approval_task_executions
approval_task_items
approval_task_votes
appstore_tags
async_jobs
bad_passwords
block_saves
blocks
blueprints_appstore_tags
blueprints
branches
commits
component_metadata
config_var_values
config_vars
custom_component_collection_revision_files
custom_component_collection_revisions
custom_component_collections
custom_domains
dg_activity
dg_bulk_edit
dg_grid
dg_single_edit
email_verification_tokens
embeds
environment_config_vars
environments
event_workflows
experiment_audiences
experiment_strategies
experiments
external_embed_sessions
external_users
features
flow_input_schemas
flow_queries
flow_stages
flow_task_histories
flow_task_inputs
flow_tasks
flows
folder_favorites
folders
form_fields
forms
grid_field
grid_group_access
grid_table_group_access
grid_table_user_access
grid_user_access
grid_view
group_folder_defaults
group_pages
group_resource_folder_defaults
group_resources
group_workflows
groups
iam_credentials
instrumentation_integrations
language_configuration_save
language_configuration
mobile_settings
notification_applications
notification_subscribed_devices
notification_topic_subscriptions
org_image_blobs
organization_email_domains
organization_user_attributes
page_docs
page_favorites
page_onboarding_state
page_save_playground_query_saves
page_user_heartbeats
pages
partially_registered_users
personal_access_tokens
plan_features
plans
playground_queries
playground_query_saves
query_metadata
recently_visited_apps
resource_folders
resource_preview_hints
retool_databases
retool_db_migrations
retool_db_provision
retool_files
retool_managed_note_comment
retool_managed_note
retool_rules
retool_table_events
retool_tables
role_pages_members
role_pages
secrets_manager_configs
SequelizeMeta
sessions
source_control_deployment_settings
source_control_deployments
source_control_protection_status
source_control_provider_configs
source_control_relationships
source_control_repo_migration_logs
source_control_repo_migrations
source_control_settings
source_control_user_info
source_control_uuid_mappings
ssh_keys
startup_programs
storage_blobs
tags
temporal_cloud_settings
temporal_cloud_tls_configs
themes
tracked_property_usages
translations
user_groups
user_invite_groups
user_invite_suggestions
user_invites
user_login_ip_addresses
user_session_states
user_viewed_features
vectors
vscode_sessions
vscode_types
workflow_aggregate_usage
workflow_block_result_location_enum
workflow_block_results
workflow_block_runs
workflow_compression_scheme_enum
workflow_custom_url_path
workflow_release
workflow_run_logs
workflow_run
workflow_save
workflow_tracked_property_usages
workflow_trigger
workflow
workspaces

1. Export data from Retool's Docker container

To export data from Retool's PostgreSQL container, run the following command on the virtual machine hosting the Retool containers, in the Retool directory.

docker compose exec postgres \
pg_dump hammerhead_production --no-acl --no-owner --clean \
-U retool_internal_user -f retool_db_dump.sql

This dumps the data into a file named retool_db_dump.sql in the root of the volume used by the Retool PostgreSQL container.

To export data to your host machine, run the following command.

docker compose exec postgres \
pg_dump hammerhead_production --no-acl --no-owner --clean \
-U retool_internal_user > retool_db_dump.sql

2. Migrate the data to an external hosted database

Retool recommends using PostgreSQL 13.7 for the external database.

To migrate the data to an external database, run the following command. Replace $DB_CONNECTION_URI with the PostgreSQL connection string that connects to your externally hosted database. Make sure to correctly format the URI.

docker compose exec postgres \
psql $DB_CONNECTION_URI -f retool_db_dump.sql

3. Create a user with superuser privileges

Some databases grant superuser privileges to the first user added to the database, but you should check your database's documentation to learn more. Depending on your database, you might need to create a user. Some examples include the:

  • rds_superuser for Amazon RDS.
  • cloudsqlsuperuser for Google Cloud SQL.
  • azure_pg_admin Azure Database for PostgreSQL.

4. Configure Retool to use the external database

The docker.env files defines several Retool options, including which database to connect to. The lines you need to edit follow this pattern:

POSTGRES_DB=hammerhead_production
POSTGRES_USER=retool_internal_user
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_PASSWORD={a random string}

Edit those variables to correspond with the database you created. For example:

POSTGRES_DB=retooldb
POSTGRES_USER=retool_user
POSTGRES_HOST=retool.xxxxxxxxxx.us-east-2.rds.amazonaws.com
POSTGRES_PORT=5432
POSTGRES_PASSWORD=xyzabc

Alternatively, you can delete the five environment variables and instead specify a database connection string:

DATABASE_URL=postgres://retool_user:xyzabc@retool.xxxxxxxxxx.us-east-2.rds.amazonaws.com:5432/retooldb

5. Restart the Retool server

After updating the Retool configuration, run this command from the retool-onpremise directory to restart the server.

sudo docker compose up -d