Docs
Migrations

pg_dump / psql import

The concrete dump-and-restore path for moving any Postgres database into Silos.

pg_dump and psql are the standard PostgreSQL tools for exporting and importing a database. Because Silos runs real Postgres and speaks the standard wire protocol, the dump-and-restore flow you'd use between any two Postgres servers works for importing into Silos — no Silos-specific tooling required.

Match your client tools to your data. Using pg_dump/psql from a recent PostgreSQL release avoids version-mismatch surprises when restoring into Silos.

Set up connection strings

You'll work with two connection strings: your source database and your Silos destination.

Terminal
# Your existing database
export SOURCE_URL="postgres://user:password@source-host:5432/mydb"

# Your Silos database — find it in the Console or via the CLI
export SILOS_URL="postgres://user:password@db-xxxx.silos.sh/main?sslmode=require"

Get the Silos connection string from the Console or the CLI:

Terminal
silos db connection-string my-app

Plain SQL dump and restore

The simplest, most portable path is a plain-SQL dump piped (or saved and replayed) into the destination.

Dump the source

Terminal
pg_dump "$SOURCE_URL" --no-owner --no-privileges -Fp -f dump.sql

--no-owner and --no-privileges strip role/ownership and grant statements that reference roles which may not exist in the destination — the usual cause of restore errors when moving between platforms.

Restore into Silos

Terminal
psql "$SILOS_URL" -f dump.sql

Or do it in one pipe without an intermediate file:

Terminal
pg_dump "$SOURCE_URL" --no-owner --no-privileges | psql "$SILOS_URL"

Verify

Spot-check that your tables and row counts came across:

Terminal
psql "$SILOS_URL" -c "\dt"
psql "$SILOS_URL" -c "SELECT count(*) FROM your_table;"

Custom-format dumps

For larger databases, the custom format (-Fc) supports parallel restore and selective object restore via pg_restore.

Terminal
# Dump
pg_dump "$SOURCE_URL" --no-owner --no-privileges -Fc -f dump.dump

# Restore
pg_restore --no-owner --no-privileges -d "$SILOS_URL" dump.dump

Schema first, then data

If you'd rather review the schema before loading data — or apply it through silos silo — dump them separately:

Terminal
pg_dump "$SOURCE_URL" --schema-only --no-owner -f schema.sql
pg_dump "$SOURCE_URL" --data-only --no-owner -f data.sql

psql "$SILOS_URL" -f schema.sql
psql "$SILOS_URL" -f data.sql

Before you import

  • Check extensions. Make sure any extensions your dump enables are available in the Silos WASM runtime; some heavyweight ones aren't. See Extensions.
  • Test on a branch. Restore into a branch or a throwaway database first, validate, then import into the real target.
  • Mind TLS. Keep sslmode=require on the Silos URL — connections require TLS.

Always validate a restore (schema, row counts, a few real queries) before pointing production traffic at the imported database.

Next steps

On this page