Skip to content

Infrastructure Commands

Graft allows you to run shared infrastructure like Postgres and Redis that multiple projects can use.

Initialize a managed Postgres database.

Terminal window
graft db mydb init

What it does:

  • Creates a database in the shared Postgres container.
  • Generates a connection URL.
  • Saves the secret as GRAFT_POSTGRES_<NAME>_URL.

Usage in graft-compose.yml:

environment:
- DATABASE_URL=${GRAFT_POSTGRES_MYDB_URL}

Initialize a managed Redis instance.

Terminal window
graft redis mycache init

What it does:

  • Creates a Redis database (separate DB number).
  • Generates a connection URL.
  • Saves the secret as GRAFT_REDIS_<NAME>_URL.

Manage port visibility for shared infrastructure services.

Terminal window
# Reveal Postgres port 5432 to the internet
graft infra db ports:5432
# Hide Postgres port from the internet
graft infra db ports:null

Pull and reload infrastructure services (Postgres and Redis).

Terminal window
graft infra reload

Schedule or run an automated database backup to an S3-compatible service.

Terminal window
graft infra db backup

Interactive Flow:

  1. S3 Config: Provide Endpoint, Region, Bucket, Access Key, and Secret Key.
  2. Scheduling: Choose to enable daily backups via cron (2 AM).
  3. Save Info: Choose to persist credentials on the server.
  4. Immediate Backup: Option to run the first backup immediately to verify setup.