CLI
Installation
Section titled “Installation”# npmnpm install -g @bunbase/cli
# bunbun install -g @bunbase/cli
# one-shot (no install)bunx @bunbase/cli <command>Verify:
bunbase --versionCommands
Section titled “Commands”| Command | Description |
|---|---|
bunbase init | Scaffold a new BunBase project |
bunbase backup | Download a database backup |
bunbase restore <file> | Upload and restore a backup |
bunbase deploy | Deploy to a VPS via rsync + SSH |
bunbase update | Update the CLI to the latest version |
Run bunbase <command> --help for per-command options.
bunbase init
Section titled “bunbase init”Scaffold a new self-hosted BunBase deployment in the target directory.
bunbase initbunbase init --dir ./myapp --name myapp --port 3000Creates:
| File | Purpose |
|---|---|
.env | Server environment variables with generated secrets |
docker-compose.yml | Run BunBase as a Docker service |
bunbase.config.ts | CLI config (URL, admin key, deploy settings) |
data/ | Persistent data directory (mounted by Docker) |
Options:
| Flag | Default | Description |
|---|---|---|
--dir <path> | Current directory | Target directory |
--name <name> | Directory name | Project name |
--port <port> | 3000 | Server port |
Existing files are never overwritten — re-running
initis safe.
bunbase backup
Section titled “bunbase backup”Download a full database backup from your running server.
bunbase backupbunbase backup --url https://api.example.com --key <admin-key> --out my-backup.dbOptions:
| Flag | Default | Description |
|---|---|---|
--url <url> | Config / http://localhost:3000 | Server URL |
--key <key> | Config / BUNBASE_ADMIN_KEY env | Admin key |
--out <file> | bunbase-backup-<timestamp>.db | Output filename |
bunbase restore <file>
Section titled “bunbase restore <file>”Upload a backup file and restore the database. The server restarts automatically.
bunbase restore bunbase-backup-1234567890.dbbunbase restore bunbase-backup-1234567890.db --yes # skip confirmationOptions:
| Flag | Default | Description |
|---|---|---|
--url <url> | Config / http://localhost:3000 | Server URL |
--key <key> | Config / BUNBASE_ADMIN_KEY env | Admin key |
--yes | false | Skip confirmation prompt |
Destructive. This replaces the live database. You will be asked to confirm unless
--yesis passed.
bunbase deploy
Section titled “bunbase deploy”Sync your project to a remote VPS via rsync, then SSH in to run the restart command.
bunbase deploybunbase deploy --host user@vps.example.com --path /opt/bunbasebunbase deploy --dry-run # print commands without executingOptions:
| Flag | Default | Description |
|---|---|---|
--host <user@host> | Config deploy.host | SSH target |
--path <path> | Config deploy.path / /opt/bunbase | Remote path |
--restart <cmd> | Config deploy.restart / pm2 restart bunbase | Post-sync command |
--dry-run | false | Print commands only |
Automatically excluded from rsync: .git, node_modules, data/, *.db, *.db-shm, *.db-wal, dist/, .env
.envis never synced — manage secrets on the server separately.
bunbase update
Section titled “bunbase update”Update the CLI to the latest version published on npm.
bunbase updateDetects which package manager installed the CLI (Bun, npm, or pnpm) and runs the appropriate global install command.
Config file
Section titled “Config file”Place a bunbase.config.ts (or .json) in your project root to avoid repeating flags:
import type { BunBaseConfig } from '@bunbase/cli';
const config: BunBaseConfig = { url: 'https://api.example.com', adminKey: process.env.BUNBASE_ADMIN_KEY,
deploy: { host: 'user@vps.example.com', path: '/opt/bunbase', restart: 'cd /opt/bunbase && docker compose pull && docker compose up -d', },};
export default config;Resolution order: bunbase.config.ts → bunbase.config.js → bunbase.config.mjs → bunbase.config.json
Field priority: CLI flag → config file → built-in default
Auto update check
Section titled “Auto update check”After every command, the CLI silently checks npm for a newer version (at most once per 24 hours). If one is available, a notice is printed:
Update available! 0.14.0 → 0.14.1Run bunbase update to upgrade.The check result is cached in ~/.bunbase/update-check.json and never blocks command execution.