ff-serv) with database utilities for pulling and dumping PostgreSQL databases.
Installation
ff-serv in your node_modules/.bin or via bun run.
Commands
db pull
Pull a database from a source and restore it to a target database.
- Interactive prompts for configuration
- Automatic schema introspection and truncation
- Retry on failure
- Save dump file for reuse
--fromDump <path>: Use an existing dump file instead of downloading--saveDump <path>: Save the dump file to a specific location--config <path>: Path to config file
- Source Selection: Choose source database (from config or manual input)
- Confirmation: Review source and target database details
- Dump: Downloads database dump to temp file
- Schema Review: Shows all tables that will be truncated
- Truncation: Confirms and truncates target database
- Restore: Restores data from dump file
- Cleanup: Optionally removes temp dump file
db dump
Dump a database to a SQL file.
--output <path>or-o <path>: Output file path (default:./dump.sql)--config <path>: Path to config file
Configuration File
Createff-serv.config.json to store database sources:
Cloudflare R2 Source
Load dumps from Cloudflare R2:Complete Workflow
Setup
- Create config file:
ff-serv.config.json
- Pull database:
- Review the output:
- Confirm truncation:
- Wait for restore:
Error Handling
If an error occurs during pull:- Dump file is preserved
- You’re prompted to retry
- Can resume with
--fromDumpflag
Use Cases
Daily Development Sync
Backup Before Migration
CI/CD Test Database
.github/workflows/test.yml
Implementation Details
The CLI uses:- @effect/cli for command parsing
- inquirer for interactive prompts
- postgres for database introspection
psqlandpg_dumpfor dump/restore operations
Database Introspection
The CLI introspects schemas and tables to show what will be truncated:Truncation
UsesTRUNCATE ... RESTART IDENTITY CASCADE: