Self-service maintenance

This page describes self-service maintenance, which lets you accept a maintenance update on your instance outside of the normal flow of scheduled maintenance.

Overview

Cloud SQL regularly releases software improvements, such as patches for known vulnerabilities, through new maintenance versions. While Cloud SQL schedules maintenance updates once every few months to ensure you have the latest maintenance version, you might want to use self-service maintenance if:

  • You need an update sooner than your next scheduled maintenance event.
  • You want to catch up to the latest maintenance version after skipping your most recent scheduled maintenance event.

You're not required to manually upgrade to the latest version. You can let Cloud SQL automatically upgrade your maintenance version during your next scheduled maintenance event.

Before you begin

Before you perform self-service maintenance, first check your current maintenance version. Then you can determine the target maintenance version you want to upgrade your instance to and upgrade your instance to that version.

Use the following method to see your current maintenance version.

gcloud

Before using the gcloud command below, make the following replacements

  • INSTANCE_ID: The instance to query
gcloud sql instances describe INSTANCE_ID
  

The maintenance version is indicated beside the maintenanceVersion attribute.

REST v1

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "SQLSERVER_2019_STANDARD"
}

Look for the maintenanceVersion item in the DatabaseInstance section of the response.

REST v1beta4

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "SQLSERVER_2019_STANDARD"
}

Look for the maintenanceVersion item in the DatabaseInstance section of the response.

Determine the target maintenance version

Use the following method to view the maintenance versions you can select as your target. Note that you can't upgrade to a version earlier than the current maintenance version.

gcloud

Before using the gcloud command below, make the following replacements

  • INSTANCE_ID: The instance to query
gcloud sql instances describe INSTANCE_ID
  

The list of available maintenance versions is indicated beside the availableMaintenanceVersions attribute.

REST v1

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "SQLSERVER_2019_STANDARD"
}

Look for the availableMaintenanceVersions item in the DatabaseInstance section of the response.

REST v1beta4

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID

HTTP method and URL:

GET https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#instance",
  "state": "RUNNABLE",
  "databaseVersion": "SQLSERVER_2019_STANDARD"
}

Look for the availableMaintenanceVersions item in the DatabaseInstance section of the response.

Upgrade to the target maintenance version

Use the following method to upgrade your instance to the target maintenance version.

gcloud

Before using the gcloud command below, make the following replacements

  • INSTANCE_ID: The instance to query
  • MAINTENANCE_VERSION: the maintenance version to apply
gcloud sql instances patch INSTANCE_ID \
--maintenance-version=MAINTENANCE_VERSION
  

REST v1

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID
  • maintenance-version: the maintenance version to use

HTTP method and URL:

POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id

Request JSON body:

{
  "maintenanceVersion": "maintenance-version"
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2020-01-16T02:32:12.281Z",
  "startTime": "08:00",
  "endTime": "08:01",
  "operationType": UPDATE,
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/v1/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}

REST v1beta4

Before using any of the request data, make the following replacements:

  • project-id: The project ID
  • instance-id: The instance ID
  • maintenance-version: the maintenance version to use

HTTP method and URL:

POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id

Request JSON body:

{
  "maintenanceVersion": "maintenance-version"
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id",
  "status": "PENDING",
  "user": "user@example.com",
  "insertTime": "2020-01-16T02:32:12.281Z",
  "startTime": "08:00",
  "endTime": "08:01",
  "operationType": UPDATE,
  "name": "operation-id",
  "targetId": "instance-id",
  "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id",
  "targetProject": "project-id"
}