LinuxCommandLibrary

doctl-databases-replica

Manage DigitalOcean database replica instances

TLDR

Run a doctl databases replica command with an access token

$ doctl [[d|databases]] [[r|replica]] [command] [[-t|--access-token]] [access_token]
copy

Retrieve information about a read-only database replica
$ doctl [[d|databases]] [[r|replica]] [[g|get]] [database_id] [replica_name]
copy

Retrieve list of read-only database replicas
$ doctl [[d|databases]] [[r|replica]] [[ls|list]] [database_id]
copy

Create a read-only database replica
$ doctl [[d|databases]] [[r|replica]] [[c|create]] [database_id] [replica_name]
copy

Delete a read-only database replica
$ doctl [[d|databases]] [[r|replica]] [[rm|delete]] [database_id] [replica_name]
copy

SYNOPSIS

doctl databases replica <subcommand> <CLUSTER-ID> [<REPLICA-ID>] [flags]

PARAMETERS

create
    Create a new read replica for the cluster

list
    List replicas for the cluster

get
    Get details of a specific replica

delete
    Delete a specific replica

--engine-version
    Engine version (must match primary; auto-detected if omitted)

--name
    Human-readable name for the replica

--node-count
    Number of nodes (1 for single-node; default 1)

--region
    Datacenter region for the replica (must match primary unless cross-region)

--size
    Droplet size slug (e.g., db-s-1vcpu-1gb)

--tags
    Comma-separated tags for the replica

--format
    Output format (json, yaml, wide)

--no-header
    Suppress column headers in table output

--output
    Output encoding (json, yaml)

--verbose
    Enable verbose output

DESCRIPTION

The doctl databases replica command manages read replicas for DigitalOcean Managed Databases. Read replicas are asynchronous, read-only copies of the primary database cluster, ideal for scaling read-heavy workloads, failover, or disaster recovery.

Key subcommands include:
create: Provisions a new replica for a cluster.
list: Lists all replicas for a given cluster.
get: Retrieves details for a specific replica.
delete: Terminates a replica.

Replicas share the same engine (MySQL, PostgreSQL, etc.) and version as the primary. They support private networking and can be tagged. Creation typically takes 5-15 minutes. Replicas lag slightly behind the primary due to asynchronous replication. Use requires a DigitalOcean API token configured via doctl auth init.

CAVEATS

Replicas incur additional costs; deletion is irreversible. Cross-region replicas unsupported for all engines. Lag may reach seconds under heavy load. Requires doctl v1.20+.

EXAMPLE USAGE

doctl databases replica create abc123 --size db-s-1vcpu-1gb --region nyc1 --name my-replica
doctl databases replica list abc123
doctl databases replica delete abc123/xyz789 --force

REQUIREMENTS

API token via doctl auth init; cluster must support replicas (PostgreSQL 11+, MySQL 8.0+)

HISTORY

Part of doctl CLI (v1.0+ in 2018); replica support added ~2020 with Managed Databases read replica feature.

SEE ALSO

doctl(1), doctl-databases(1), doctl-databases-cluster(1)

Copied to clipboard