doctl Verified current stable Not installed? Cloud Infrastructure

Doctl / List Database Replicas

List Database Replicas

List all replicas for a specified database within the DigitalOcean account.

$
Terminal
doctl d r ls <database_id>

When To Use

After a primary database failover to verify the replicas are operational.

Pro Tip

Combine with `--format` for streamlined output, especially during post-migration verifications.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
ID            Name               Status      Region         Created At
-------------------------------------------------------------
12345678     replica-db-1      active      nyc1           2023-10-01T12:00:00Z
87654321     replica-db-2      active      nyc1           2023-10-01T12:05:00Z

Anatomy of Output

Understanding the result

ID Name Status Size Region Header

Describes columns displaying replicas.

789012 replica-1 active db-s-1vcpu-2gb nyc1 Replica Entry

Status shows that this replica is functioning.

789013 replica-2 inactive db-s-1vcpu-2gb sfo2 Replica Entry

Indicates that this replica is currently offline.

Power User Variants

Optimized versions

doctl databases replica list --format ID,Name

Optimize output for specific replica attributes.

Unix Pipeline

Shell combinations

doctl databases replica list --region nyc1

Filter replicas by region.

Troubleshooting

Common pitfalls

Error: Database not found

Solution: Ensure that the specified database ID is correct.

Error: No replicas exist for this database

Solution: Validate the database configuration for replica settings.

Error: Unauthorized

Solution: Confirm your access token and scopes allow listing database replicas.

Command Breakdown

What each part is doing

doctl
Base Command
The executable that performs this operation. Here it runs Doctl before the shell applies any redirect operators.
d
d|databases
The value supplied for d|databases.
r
r|replica
The value supplied for r|replica.
ls
ls|list
The value supplied for ls|list.
<database_id>
database id
The value supplied for database id.

How To Run

Execution path

  1. Step 1

    Run `doctl databases replica ls <database_id>` to list replicas.

  2. Step 2

    Check the status column for operational status.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.