Infrastructure Commands
Graft allows you to run shared infrastructure like Postgres and Redis that multiple projects can use.
graft db <name> init
Section titled “graft db <name> init”Initialize a managed Postgres database.
graft db mydb initWhat 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}graft redis <name> init
Section titled “graft redis <name> init”Initialize a managed Redis instance.
graft redis mycache initWhat it does:
- Creates a Redis database (separate DB number).
- Generates a connection URL.
- Saves the secret as
GRAFT_REDIS_<NAME>_URL.
graft infra [db|redis] ports:<value>
Section titled “graft infra [db|redis] ports:<value>”Manage port visibility for shared infrastructure services.
# Reveal Postgres port 5432 to the internetgraft infra db ports:5432
# Hide Postgres port from the internetgraft infra db ports:nullgraft infra reload
Section titled “graft infra reload”Pull and reload infrastructure services (Postgres and Redis).
graft infra reloadgraft infra db backup
Section titled “graft infra db backup”Schedule or run an automated database backup to an S3-compatible service.
graft infra db backupInteractive Flow:
- S3 Config: Provide Endpoint, Region, Bucket, Access Key, and Secret Key.
- Scheduling: Choose to enable daily backups via cron (2 AM).
- Save Info: Choose to persist credentials on the server.
- Immediate Backup: Option to run the first backup immediately to verify setup.