CLI: Database Management
Manage databases with the agentmetal database subcommand.
CLI: Database Management
Overview
The agentmetal database subcommand manages fully managed database instances. AgentMetal supports PostgreSQL and MySQL engines with automated backups, replication, and failover.
Operations
Create a Database
agentmetal database create \
--name my-postgres \
--engine postgresql \
--type db-s-2vcpu-4gb \
--vpc vpc-abc123
| Flag | Required | Description |
|---|---|---|
--name | Yes | Database instance name |
--engine | Yes | Database engine: postgresql or mysql |
--type | Yes | Instance type / size |
--vpc | No | VPC ID for network placement |
--version | No | Engine version (e.g., 15 for PostgreSQL) |
--storage | No | Storage size in GB (default: 20) |
--replicas | No | Number of read replicas (default: 0) |
--backup | No | Enable automated backups (default: true) |
--backup-schedule | No | Cron expression for backup schedule |
agentmetal database list
Example output:
ID NAME ENGINE VERSION STATE VPC
db-a1b2c3 my-postgres postgresql 15 running vpc-abc123
db-d4e5f6 app-mysql mysql 8.0 running vpc-abc123
Get Database Details
agentmetal database get db-a1b2c3
Returns the full database spec including connection endpoint, port, status, and replica information.
Delete a Database
agentmetal database delete db-a1b2c3
Deletes the database instance and all associated replicas. This operation is asynchronous and returns an operation ID.
Examples
Create a PostgreSQL database with replicas and backups:
agentmetal database create \
--name production-db \
--engine postgresql \
--type db-s-4vcpu-8gb \
--vpc vpc-abc123 \
--version 15 \
--storage 100 \
--replicas 2 \
--backup true \
--backup-schedule "0 2 *"
Create a MySQL database:
agentmetal database create \
--name analytics-db \
--engine mysql \
--type db-s-2vcpu-4gb \
--vpc vpc-abc123 \
--version 8.0
List databases as JSON:
agentmetal database list --output json | jq '.[].metadata.name'
DatabaseSpec Fields
| Field | Type | Description |
|---|---|---|
engine | string | postgresql or mysql |
type | string | Instance type for the database server |
version | string | Engine version |
vpc_id | string | VPC for network placement |
storage_gb | int | Allocated storage in gigabytes |
replicas | int | Number of read replicas |
backup_enabled | bool | Whether automated backups are enabled |
backup_schedule | string | Cron expression for backup timing |