Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

CLI Reference

Complete reference for the Postbase command-line interface.

Installation

npm install -g postbase

Global Options

postbase [command] [options]
 
Options:
  -V, --version    Output version number
  -h, --help       Display help for command
  --json           Output in JSON format (where supported)
  --quiet          Suppress non-essential output

Commands Overview

Local Development

CommandDescription
postbase startStart the Postbase daemon
postbase stopStop the daemon
postbase statusShow daemon status
postbase dbDatabase management
postbase migrateMigration operations
postbase connectGet connection details
postbase typesGenerate TypeScript types

Cloud Platform

CommandDescription
postbase cloud loginAuthenticate with GitHub
postbase cloud logoutClear credentials
postbase cloud projectsManage projects
postbase cloud provisionCreate cloud database
postbase cloud urlGet connection string
postbase cloud destroyDelete cloud database
postbase cloud backupsBackup operations
postbase cloud pitrPoint-in-Time Recovery

Command Reference

postbase start

Start the Postbase daemon and PostgreSQL container.

postbase start [options]
 
Options:
  --port <port>     Daemon API port (default: 9432)
  --pg-port <port>  PostgreSQL port (default: 5432)
  --data-dir <dir>  Data directory (default: ~/.postbase)
Examples:
# Start with defaults
postbase start
 
# Custom ports
postbase start --port 9000 --pg-port 5433

postbase stop

Stop the Postbase daemon.

postbase stop [options]
 
Options:
  --force           Force stop without confirmation
  --keep-container  Keep PostgreSQL container running

postbase status

Show daemon and database status.

postbase status [options]
 
Options:
  --json    Output in JSON format
Output:
Postbase Status
 
Daemon:     Running (PID: 12345)
API:        http://localhost:9432
PostgreSQL: Running (Port: 5432)
Databases:  3
 
Databases:
  - myapp (12.5 MB)
  - demo (3.2 MB)
  - test (1.1 MB)

postbase db

Database management commands.

postbase db <command>
 
Commands:
  list              List all databases
  create <name>     Create a new database
  drop <name>       Delete a database
  info <name>       Show database details
Examples:
# List databases
postbase db list
 
# Create database
postbase db create myapp
 
# Create from template
postbase db create myapp_test --template myapp
 
# Get database info
postbase db info myapp
 
# Delete database
postbase db drop myapp
postbase db drop myapp --force

postbase migrate

Migration management commands.

postbase migrate <command>
 
Commands:
  new <name>        Create new migration files
  up                Apply pending migrations
  down              Rollback migrations
  status            Show migration status
Options:
# Common options
--database <name>   Target database (default: from config)
--schema <name>     Target schema (default: public)
--dir <path>        Migrations directory (default: ./migrations)
Examples:
# Create migration
postbase migrate new create_users
 
# Apply all pending
postbase migrate up
 
# Apply to specific database
postbase migrate up --database myapp
 
# Apply to specific schema
postbase migrate up --schema auth
 
# Dry run
postbase migrate up --dry-run
 
# Rollback last migration
postbase migrate down
 
# Rollback multiple
postbase migrate down --count 3
 
# Check status
postbase migrate status

postbase connect

Get database connection details.

postbase connect <database> [options]
 
Options:
  --copy            Copy connection string to clipboard
  --json            Output in JSON format
Example:
postbase connect myapp
Output:
Database: myapp
 
Connection Details:
  Host:     localhost
  Port:     5432
  Database: myapp
  User:     postgres
  Password: postgres
 
Connection String:
  postgresql://postgres:postgres@localhost:5432/myapp

postbase types

Generate TypeScript types from database schema.

postbase types generate [options]
 
Options:
  --database <name>    Database name
  --output <path>      Output file path
  --all                Include functions, views, enums
  --include-functions  Include PostgreSQL functions
  --include-views      Include views
  --include-enums      Include enum types
  --schema <name>      Target schema (default: public)
  --dates-as-strings   Map timestamps to string
Example:
postbase types generate \
  --database myapp \
  --all \
  --output ./src/db/types.ts

postbase cloud login

Authenticate with GitHub OAuth.

postbase cloud login

Opens browser for GitHub authentication using device flow.

postbase cloud projects

Manage cloud projects.

postbase cloud projects <command>
 
Commands:
  list              List all projects
  create <name>     Create a new project
  delete <id>       Delete a project
Examples:
# List projects
postbase cloud projects list
 
# Create project
postbase cloud projects create myapp
 
# Delete project
postbase cloud projects delete proj_xxx --force

postbase cloud provision

Create a cloud PostgreSQL database.

postbase cloud provision <name> [options]
 
Options:
  -p, --project <id>   Project ID
  --region <region>    Deployment region
  --cpu <vCPUs>        CPU cores (1, 2, 4, 8)
  --memory <MB>        Memory in MB (1024, 2048, 4096, 8192)
  --storage <GB>       Storage in GB (10, 25, 50, 100)
Examples:
# Basic provisioning
postbase cloud provision production -p myapp
 
# With configuration
postbase cloud provision production \
  -p myapp \
  --region us-west1 \
  --cpu 2 \
  --memory 4096 \
  --storage 50

postbase cloud url

Get cloud database connection string.

postbase cloud url <database> [options]
 
Options:
  -p, --project <id>   Project ID
  --copy               Copy to clipboard

postbase cloud backups

Backup management commands.

postbase cloud backups <command>
 
Commands:
  list              List backups
  create            Create manual backup
  download <id>     Download backup file
  restore <id>      Restore from backup
  delete <id>       Delete manual backup
Options:
-p, --project <id>    Project ID
-d, --database <name> Database name
Examples:
# List backups
postbase cloud backups list -p myapp -d production
 
# Create backup
postbase cloud backups create -p myapp -d production
 
# Download backup
postbase cloud backups download bkp_xxx \
  -p myapp -d production \
  -o backup.sql
 
# Restore from backup
postbase cloud backups restore bkp_xxx \
  -p myapp -d production
 
# Delete backup
postbase cloud backups delete bkp_xxx \
  -p myapp -d production --force

postbase cloud pitr

Point-in-Time Recovery commands.

postbase cloud pitr <command>
 
Commands:
  status            Show PITR status
  enable            Enable PITR
  disable           Disable PITR
  wal               List WAL archives
  restore           Restore to point in time
  restores          List restore operations
  receiver          Show WAL receiver status
  restart-receiver  Restart WAL receiver
  service-status    Show backup service status
Options:
-p, --project <id>    Project ID
-d, --database <name> Database name
Examples:
# Check status
postbase cloud pitr status -p myapp -d production
 
# Enable PITR
postbase cloud pitr enable -p myapp -d production
 
# List WAL archives
postbase cloud pitr wal -p myapp -d production
 
# Restore to specific time
postbase cloud pitr restore \
  -p myapp -d production \
  --target-time "2026-01-25T14:30:00Z" \
  --force
 
# Restore to latest
postbase cloud pitr restore \
  -p myapp -d production \
  --target-time latest \
  --force
 
# Check restore status
postbase cloud pitr restores -p myapp -d production
 
# Check WAL receiver health
postbase cloud pitr receiver -p myapp -d production
 
# Restart WAL receiver
postbase cloud pitr restart-receiver -p myapp -d production

Environment Variables

VariableDescriptionDefault
POSTBASE_API_URLCloud API URLhttps://api.postbase.sh
POSTBASE_DAEMON_URLLocal daemon URLhttp://localhost:9432
POSTBASE_DATA_DIRData directory~/.postbase
DATABASE_URLDefault connection string-

Configuration File

postbase.toml:

[project]
name = "myapp"
 
[database]
name = "myapp"
 
[migrations]
directory = "./migrations"
schema = "public"
 
[daemon]
port = 9432
 
[postgresql]
port = 5432