Skip to content

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.dump

The default format is custom (pg_dump -Fc), which is compact and supports parallel restores. Override with --format:

FormatFlagNotes
custom (default)-FcBinary archive; pairs with pg_restore
plain-FpHuman-readable SQL; pairs with psql
tar-FtArchive format pg_restore understands
directory-FdDirectory 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.sql

Schema 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.dump

restore 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.dump

Useful flags (archive-format only):

FlagEffect
--cleanDrop existing objects before recreating them
--no-ownerDon't try to set object ownership
--jobs <n>Parallel restore workers
bash
vibepg restore demo backup.dump --clean --jobs 4 --no-owner

Round-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 --clean

Scripted 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_dump on your host
  • Custom-format dumps are not human-readable — keep a --format plain companion for emergency manual edits if that matters to you
  • Restore is destructive when --clean is set; double-check the target instance name

Released under the MIT License.