doctl Verified current stable Not installed? Cloud Infrastructure

Doctl / Run Doctl Databases Replica Command

Run Doctl Databases Replica Command

Execute a command on a specific database replica.

$
Terminal
doctl d r <command> -t <access_token>

When To Use

When performing maintenance tasks on a replica database without direct access.

Pro Tip

Check the replica's status using `doctl databases replica list` before executing commands to avoid errors.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
doctl d r <command> -t <access_token>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
$ doctl databases replica command --access-token abc123xyz

Replica Database Command:
+----------------+----------------+----------------+----------------+
| ID             | Name           | Status         | Region         |
+----------------+----------------+----------------+----------------+
| 123456         | my-replica-db  | active         | nyc1           |
+----------------+----------------+----------------+----------------+

Anatomy of Output

Understanding the result

Executing command on replica: example-replica Execution Status

Indicates which replica the command is being executed on.

Command output: Command executed successfully Output

Confirms the command ran without error.

Power User Variants

Optimized versions

doctl databases replica run --access-token TOKEN sql 'SHOW DATABASES;'

Run SQL command directly on the replica without invoking a separate command.

Unix Pipeline

Shell combinations

doctl databases replica run command --help

Displays help for all command options and usage.

Troubleshooting

Common pitfalls

Error: Replica not found

Solution: Ensure that the replica_id specified is correct.

Error: Command execution failed

Solution: Check the command syntax and parameters for accuracy.

Error: Unauthorized access

Solution: Confirm that your access token has permission to execute commands on the replica.

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.
<command>
command
The value supplied for command.
-t
t| access token
The value supplied for t| access token.
<access_token>
access token
The value supplied for access token.
-t
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: `doctl databases replica command --access-token YOUR_ACCESS_TOKEN`

  2. Step 2

    Check the output for the status of the replica database.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.