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
FlagRequiredDescription
--nameYesDatabase instance name
--engineYesDatabase engine: postgresql or mysql
--typeYesInstance type / size
--vpcNoVPC ID for network placement
--versionNoEngine version (e.g., 15 for PostgreSQL)
--storageNoStorage size in GB (default: 20)
--replicasNoNumber of read replicas (default: 0)
--backupNoEnable automated backups (default: true)
--backup-scheduleNoCron expression for backup schedule
### List Databases
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

FieldTypeDescription
enginestringpostgresql or mysql
typestringInstance type for the database server
versionstringEngine version
vpc_idstringVPC for network placement
storage_gbintAllocated storage in gigabytes
replicasintNumber of read replicas
backup_enabledboolWhether automated backups are enabled
backup_schedulestringCron expression for backup timing