Skip to content

Remote Storage Overview

pgbranch supports remote storage backends, allowing you to share database snapshots with your team or sync across your own machines.

Share a known-good database state with your team:

Terminal window
# Developer A creates and pushes a branch
pgbranch branch seed-data
# ... add test data ...
pgbranch push seed-data
# Developer B pulls the same state
pgbranch pull seed-data

Everyone works with identical database states.

Sync your database branches between work and home:

Terminal window
# At work
pgbranch push feature-wip
# At home
pgbranch pull feature-wip

New team members can quickly get a working database:

Terminal window
pgbranch init -d myapp_dev
pgbranch pull seed-data
pgbranch checkout seed-data

No need to run migrations and seed scripts from scratch.

BackendURL FormatBest For
Filesystem/path/to/dir or file:///pathLocal network shares, NAS
AWS S3s3://bucket/prefixTeams using AWS
MinIOs3://bucket/prefix (with endpoint)Self-hosted S3-compatible
Cloudflare R2r2://account-id/bucket/prefixCost-effective storage

When you push a branch:

  1. pgbranch creates a compressed archive of the template database
  2. The archive is encrypted (if configured)
  3. The archive is uploaded to the remote storage
Template DB: pgbranch_main_abc123
pg_dump + compress
Encrypt (optional)
Upload to S3/R2/etc.

When you pull a branch:

  1. pgbranch downloads the archive from remote storage
  2. The archive is decrypted (if needed)
  3. The archive is restored as a local template database
Download from S3/R2/etc.
Decrypt (if needed)
Decompress + pg_restore
Template DB: pgbranch_main_abc123

Remote storage credentials are encrypted locally using a key stored in ~/.pgbranch_key. This means:

  • Config files can be safely committed to version control
  • Credentials are not exposed in plaintext
  • Each machine has its own encryption key

Learn more about encryption

Database archives can be encrypted before upload (coming soon).

Terminal window
pgbranch remote add origin s3://my-bucket/pgbranch

You’ll be prompted for credentials.

Terminal window
pgbranch push main
Terminal window
pgbranch pull main

Database archives are compressed but can still be large. Consider:

Database SizeCompressed Archive
100 MB~20-40 MB
1 GB~200-400 MB
10 GB~2-4 GB

Compression ratio depends on data content (text compresses better than binary).

  1. Prune old branches before pushing
  2. Use lifecycle policies on S3/R2 to auto-delete old archives
  3. Push only what you need (not every local branch)

Entire archives must be downloaded/uploaded. For very large databases, this can be slow.

You cannot sync individual tables or schemas - it’s always the full database.

Pushing the same branch to multiple remotes requires separate push commands.