How to Schedule Automatic Software Updates for PostgreSQL Database Clusters

PostgreSQL is an open source, object-relational database built with a focus on extensibility, data integrity, and speed. Its concurrency support makes it fully ACID-compliant, and it supports dynamic loading and catalog-driven operations to let users customize its data types, functions, and more.

DigitalOcean fully manages database software updates for database clusters on your behalf. During the update process, we create a new cluster with OS-level or db_engine updates applied, replicate the existing cluster’s data, and then update DNS (which changes the cluster’s underlying IP address).

There is no downtime associated with these updates, but there may be brief periods of latency during the maintenance window. Updates are necessary for security and stability, so you can’t disable them, but you can customize the maintenance window or manually initiate an available update.

Set a Maintenance Window Using the CLI

How to set a maintenance window using the DigitalOcean CLI

To set a maintenance window via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token, and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

                  doctl auth init
  4. Finally, set a maintenance window with doctl databases maintenance-window update. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl databases maintenance-window update <database-id> [flags]

Set a Maintenance Window Using the API

How to set a maintenance window using the DigitalOcean API

To set a maintenance window using the DigitalOcean API, follow these steps:

  1. Create a personal access token, and save it for use with the API.

  2. Send a PUT request to{database_cluster_uuid}/maintenance


    To set a maintenance window with cURL, call:

                    curl -X PUT \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      -d '{"day": "tuesday", "hour": "14:00"}' \


    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To set a maintenance window with Godo, use the following code:

                    import (
    func main() {
        token := os.Getenv("DIGITALOCEAN_TOKEN")
        client := godo.NewFromToken(token)
        ctx := context.TODO()
        maintenanceRequest := &godo.DatabaseUpdateMaintenanceRequest{
            Day:  "thursday",
            Hour: "16:00",
        _, err := client.Databases.UpdateMaintenance(ctx, "88055188-9e54-4f21-ab11-8a918ed79ee2", maintenanceRequest)


                    import os
    from pydo import Client
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    req = {
      "day": "tuesday",
      "hour": "14:00"
    update_resp = client.databases.update_maintenance_window(database_cluster_uuid="a7a8bas", body=req)

Set a Maintenance Window Using the Control Panel

The maintenance window for a cluster applies to its primary node and any standby nodes. Each read-only node has its own maintenance window that is independent of the cluster and other read-only nodes.

You can view or edit a cluster or read-only node’s current maintenance window from its Settings page, in the Maintenance Window section.

Screenshot of cluster settings page

Software updates may begin at any time in the 4-hour period after the maintenance window’s start time. For example, a maintenance window defined for Sundays at 7pm will have updates at any time between 7pm and 11pm.

To change a cluster or read-only node’s maintenance window, click Edit.

Screenshot of maintenance scheduler window

Choose the day of the week and the start time for the 4-hour maintenance window, then click Save.

Update Manually

When new updates are available, cluster and read-only node Overview pages have a banner with basic information on the update.

The maintenance banner on a database overview page

Click Update Now to open the Required maintenance window. This window specifies when the updates will be automatically applied.

The Required maintenance window with the Start Maintenance button visible

If you want to initiate the update immediately ahead of the scheduled maintenance window, click the Start Maintenance button. To manually update read-only nodes, you need to repeat this process for each individual node.