This page has procedures for finding and setting maintenance windows for Cloud SQL instances. To learn more about how and why Cloud SQL performs maintenance, see the Overview of maintenance on Cloud SQL instances.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
Set a preferred window for maintenance on an instance
Console
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- To open the Overview page of an instance, click the instance name.
- In the Maintenance section, click Edit maintenance preferences.
- In the Configuration options section, open Maintenance.
- Configure the following options:
- Preferred window. Set the day and hour range when updates can occur on this instance.
- Order of update. Set the order for updating this instance, in relation to updates to other instances. Set the timing to Any, Earlier, or Later. Instances using the Earlier setting receive updates up to a week before instances using the Later setting, when comparing instances that reside in the same location.
gcloud
Before using the gcloud command below, make the following replacements:
- instance-id: Instance to reschedule
- day: Day when you want maintenance to occur. Set to one of
SUN
,MON
,TUE
,WED
,THU
,FRI
,SAT
. - hour: Hour of day for maintenance window, in UTC time zone (0-23).
gcloud sql instances patch instance-id \ --maintenance-window-day=day \ --maintenance-window-hour=hourFor reference information, see
gcloud sql instances patch
.
If you make changes to your maintenance window setting while the instance is already undergoing maintenance or is scheduled for maintenance, then the changes don't take effect immediately. These changes are reflected in the future maintenance events.
If you've opted in to maintenance notifications, then Cloud SQL sends you notifications after an instance has been scheduled for maintenance, with the exact date and time when the maintenance is scheduled to happen. Cloud SQL sends these notifications based on your instance's maintenance window order of update settings, as follows:
- If the order of update setting is set to
Earlier
, then Cloud SQL sends maintenance notifications at least one week in advance. - If the order of update setting is set to
Later
, then Cloud SQL sends maintenance notifications at least two weeks in advance.
Opt in to maintenance notifications
Before you opt-in for maintenance notifications, you must set a preferred window for maintenance on an instance
- Go to the Communication page. Go to Communication
- In the row for Cloud SQL, Maintenance window, select the radio button under Email to turn it ON.
Each user that needs to receive notifications must opt in separately.
Find maintenance notifications in the Google Cloud console
You can view maintenance notifications in a few places in the Google Cloud console:
On the ACTIVITY dashboard, look for instances marked with SQL Maintenance.
Go to ActivityWhen an instance is scheduled for maintenance, the date for maintenance is listed on the Instances page in the Maintenance column. The Maintenance column is usually hidden, but it displays automatically when maintenance is scheduled. You can also select Maintenance from the Column display options (
) if you want the Maintenance column to always show up.
Alternatively, you can select an instance to go to the Instance details page. If the instance is scheduled for maintenance, you will see a message in the Maintenance pane.
Go to Cloud SQL instances
Find scheduled maintenance windows using the API
gcloud
Before using the gcloud
command below, make the following
replacements
- instance-id: The instance to reschedule
gcloud sql instances describe instance-id
Look for the scheduledMaintenance
section in the response.
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 scheduledMaintenance
section in 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 scheduledMaintenance
section in the response.
Reschedule planned maintenance
You may reschedule maintenance by using the Google Cloud console, gcloud
, or the
Cloud SQL Admin API.
Console
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- Filter for the term Maintenance to list all instances scheduled for maintenance.
- In the Maintenance column, click Reschedule.
- In the Reschedule dialog, choose whether to apply maintenance immediately, reschedule it to happen at a specific time within the 28 day deferral period, or defer to the next available maintenance window.
gcloud
Before using the gcloud
command below, make the following
replacements:
- instance-id: The instance to reschedule
- reschedule-type: Use one of IMMEDIATE,
NEXT_AVAILABLE_WINDOW, or SPECIFIC_TIME.
If you choose NEXT_AVAILABLE_WINDOW, maintenance is rescheduled to the next available maintenance window following the current scheduled time.
- reschedule-time: If you select SPECIFIC_TIME for reschedule-type, you also need to set this flag to specify the new day and time for maintenance to occur. Uses ISO 8601 format. For example, 2020-01-16T16:56:00.000Z
gcloud sql reschedule-maintenance instance-id \ --reschedule-type=reschedule-type \ [--schedule-time=reschedule-time]For reference information, see
gcloud sql reschedule-maintenance
.
If you want to reschedule maintenance for up to 28 days, then check the version
number of gcloud
. If the version number is below 390.0.0_RC00
,
then reinstall gcloud
.
REST v1
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
- reschedule-type: Use one of IMMEDIATE, NEXT_AVAILABLE_WINDOW, or
SPECIFIC_TIME.
If you choose NEXT_AVAILABLE_WINDOW, maintenance is rescheduled to the next available maintenance window.
HTTP method and URL:
POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id/rescheduleMaintenance
Request JSON body:
{ "reschedule": { "reschedule_type": "reschedule-type" } }
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": RESCHEDULE_MAINTENANCE, "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
- reschedule-type: Use one of IMMEDIATE, NEXT_AVAILABLE_WINDOW, or
SPECIFIC_TIME.
If you choose NEXT_AVAILABLE_WINDOW, maintenance is rescheduled to the next available maintenance window.
HTTP method and URL:
POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id/rescheduleMaintenance
Request JSON body:
{ "reschedule": { "reschedule_type": "reschedule-type" } }
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": RESCHEDULE_MAINTENANCE, "name": "operation-id", "targetId": "instance-id", "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id", "targetProject": "project-id" }
To see how the underlying REST API request is constructed for this task, see the APIs Explorer on the instances:post page.
Configure a deny maintenance period
You can configure a maximum of one deny maintenance period on a Cloud SQL instance at any given time. The deny maintenance period takes precedence over any scheduled maintenance window. If there's a conflict between the timing of a maintenance window and the deny maintenance period, the deny maintenance period overrides the maintenance window.
You can manually remove a deny maintenance period, whether it has already occurred or not.
To configure a deny maintenance period, set its start date, end date, and the time of day the interval begins and ends. A deny maintenance period can span from one to 90 days.
For start date and end date, there are two formats:
yyyy-mm-dd
: indicates a specific datemm-dd
: indicates a date recurring every year
The start date and end date are UTC. To set the timezone, use the time field to adjust the start time. For example, the start date = 2020-10-10 and the time = 07:00:00 indicate the start time 2020-10-10 07:00:00 UTC (2020-10-10 00:00:00 PST)
For time, the format is: HH:mm:SS
.
- Hours are between 0 and 23 (inclusive).
- Minutes and seconds are between 0 and 59 (inclusive).
Console
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- To open the Overview page of an instance, click the instance name.
- In the Maintenance section, click Edit maintenance preferences.
- In the Deny maintenance period section, set the start and end dates.
- In the Advanced options section, optionally select Repeat every year.
- Click Save.
gcloud
Before using the gcloud
command below, make the following
replacements:
- instance-id: Cloud SQL instance id
- start-date: Date when the interval begins. For example, 2021-11-29
- end-date: Date when the interval ends. For example, 2021-12-02
- time: Time of day for interval to start and end. For example, 00:00:00
gcloud sql instances patch instance-id\ --deny-maintenance-period-start-date=start-date \ --deny-maintenance-period-end-date=end-date \ --deny-maintenance-period-time=time
REST v1
Before using any of the request data, make the following replacements:
- project-id: The project ID
- instance-id: The instance ID
- start-date: The start date (yyyy-mm-dd) or (mm-dd) for annual recurrence
- end-date: The end date (yyyy-mm-dd) or (mm-dd) for annual recurrence
- time: The start and end time (HH:mm:SS)
HTTP method and URL:
POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
Request JSON body:
{ "settings": { "denyMaintenancePeriods": [{ "start_date": "start-date", "end_date": "end-date" "time": "time" }] } }
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": MAINTENANCE_DENY_PERIOD, "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
- start-date: The start date (yyyy-mm-dd) or (mm-dd) for annual recurrence
- end-date: The end date (yyyy-mm-dd) or (mm-dd) for annual recurrence
- time: The start and end time (HH:mm:SS)
HTTP method and URL:
POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
Request JSON body:
{ "settings": { "denyMaintenancePeriods": [{ "start_date": "start-date", "end_date": "end-date" "time": "time" }] } }
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": MAINTENANCE_DENY_PERIOD, "name": "operation-id", "targetId": "instance-id", "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id", "targetProject": "project-id" }
Remove a deny maintenance period
Console
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- To open the Overview page of an instance, click the instance name.
- In the Maintenance section, click Edit maintenance preferences.
- In the Deny maintenance period section, click Clear.
- Click Save.
gcloud
Before using the gcloud
command below, make the following
replacements:
- instance-id: Cloud SQL instance id
gcloud sql instances patch instance-id \ --remove-deny-maintenance-period
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:
POST https://sqladmin.googleapis.com/v1/projects/project-id/instances/instance-id
Request JSON body:
{ "settings": { "denyMaintenancePeriods": [] } }
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": MAINTENANCE_DENY_PERIOD, "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
HTTP method and URL:
POST https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/instances/instance-id
Request JSON body:
{ "settings": { "denyMaintenancePeriods": [] } }
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": MAINTENANCE_DENY_PERIOD, "name": "operation-id", "targetId": "instance-id", "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/project-id/operations/operation-id", "targetProject": "project-id" }
Deny maintenance period notifications
Maintenance Window notifications aren't sent when the planned maintenance time falls within the deny maintenance period and are forbidden by maintenance deny period settings.
If you change the deny maintenance period settings to prevent maintenance at a previously scheduled time, then the Cloud SQL instance skips maintenance and sends a notification about cancelling the maintenance. Cloud SQL sends this cancellation notice whenever the instance is scheduled for an update.
Notifications of planned maintenance are sent during the deny maintenance period, as long as such maintenance is scheduled to occur outside of that period.