Backups
vibepg wraps pg_dump and pg_restore with sensible defaults and runs them inside the instance's container, so you don't need either tool installed on your host.
Dumping
bash
vibepg dump demo --output backup.dumpThe default format is custom (pg_dump -Fc), which is compact and supports parallel restores. Override with --format:
| Format | Flag | Notes |
|---|---|---|
custom (default) | -Fc | Binary archive; pairs with pg_restore |
plain | -Fp | Human-readable SQL; pairs with psql |
tar | -Ft | Archive format pg_restore understands |
directory | -Fd | Directory of files; supports parallel dump |
Stream to stdout with --output - (the default):
bash
vibepg dump demo > backup.sql # plain implied via redirect, but format is still "custom" — set --format plain for SQL
vibepg dump demo --format plain > backup.sqlSchema or data only:
bash
vibepg dump demo --schema-only --format plain --output schema.sql
vibepg dump demo --data-only --output data.dump--schema-only and --data-only are mutually exclusive.
Restoring
bash
vibepg restore demo backup.dumprestore auto-detects the format — plain SQL files run through psql, archive formats through pg_restore. From stdin:
bash
cat backup.sql | vibepg restore demo -
vibepg restore demo - < backup.dumpUseful flags (archive-format only):
| Flag | Effect |
|---|---|
--clean | Drop existing objects before recreating them |
--no-owner | Don't try to set object ownership |
--jobs <n> | Parallel restore workers |
bash
vibepg restore demo backup.dump --clean --jobs 4 --no-ownerRound-trip example
Move a database from one instance to another:
bash
vibepg new staging
vibepg run staging schema.sql
# ... work happens ...
vibepg dump staging --output staging-snapshot.dump
vibepg new prod
vibepg restore prod staging-snapshot.dump --cleanScripted nightly backups
A simple cron-friendly snippet:
bash
#!/usr/bin/env bash
set -euo pipefail
INSTANCE=demo
DEST=~/backups/vibepg
TS=$(date -u +%Y%m%dT%H%M%SZ)
mkdir -p "$DEST"
vibepg dump "$INSTANCE" --output "$DEST/$INSTANCE-$TS.dump"
# keep the last 14
ls -1t "$DEST"/$INSTANCE-*.dump | tail -n +15 | xargs -r rm --vibepg dump exits non-zero if the container is missing or the dump fails, so set -e does the right thing.
Notes
- Dumps run inside the container, so you don't need
pg_dumpon your host - Custom-format dumps are not human-readable — keep a
--format plaincompanion for emergency manual edits if that matters to you - Restore is destructive when
--cleanis set; double-check the target instance name