doctl Verified current stable Not installed? Cloud Infrastructure

Doctl / Schedule Database Maintenance

Schedule Database Maintenance

Schedule a maintenance window for a database instance.

$
Terminal
doctl d mw <schedule> -t <access_token>

When To Use

When preparing for non-intrusive database upgrades and maintenance tasks.

Pro Tip

Consider the optimal time of day for maintenance to minimize operational impact; check user activity logs.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
doctl d mw <schedule> -t <access_token>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
$ doctl databases mw schedule --access-token abc123xyz

Scheduling maintenance window...

+---------------------+---------------------+---------------------+
|      DATABASE       |      STATUS         |      SCHEDULED      |
+---------------------+---------------------+---------------------+
| my-database         | Scheduled            | 2023-10-15 02:00 UTC|
+---------------------+---------------------+---------------------+

Anatomy of Output

Understanding the result

Maintenance Scheduled: Database DB-001 Database ID

The identifier for the database affected by the maintenance.

Scheduled Time: 2023-10-15 02:00 UTC Time

Indicates when the maintenance will occur.

Duration: 2 hours Duration

Expected duration for the maintenance window.

Power User Variants

Optimized versions

doctl databases maintenance-window schedule --engine postgres --duration 3h

Schedule a 3-hour window for a PostgreSQL engine.

doctl databases maintenance-window schedule --access-token YOUR_TOKEN

Use a specific access token for scheduling.

Troubleshooting

Common pitfalls

Error: Invalid schedule format

Solution: Ensure the schedule time is in UTC format with correct syntax.

Error: Database not found

Solution: Confirm that the specified database ID exists.

Error: Insufficient privileges

Solution: Validate the access token permissions for this operation.

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.
mw
mw|maintenance window
The value supplied for mw|maintenance window.
<schedule>
schedule
The value supplied for schedule.
-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 with your access token.

  2. Step 2

    Specify the database name and desired schedule.

  3. Step 3

    Confirm the scheduled maintenance in the output.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.