View and set maintenance windows

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 Maintenance updates on Cloud SQL instances.

If you've opted in to receive maintenance notifications, then Cloud SQL sends you an email notification when a maintenance update is available for your Cloud SQL instance. Cloud SQL sends a notification before the maintenance rollout and then proceeds to apply the update to groups of instances on a weekly schedule. You can control how much advance notification you receive before your instance receives the maintenance update by selecting the maintenance timing for your instance.

You have the following options for scheduling the timing of your maintenance update:

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 future maintenance events.

Before you begin

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Install the gcloud CLI.

  5. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init
  7. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  8. Verify that billing is enabled for your Google Cloud project.

  9. Install the gcloud CLI.

  10. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  11. To initialize the gcloud CLI, run the following command:

    gcloud init

Set a maintenance window on an instance

Console

  • In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  • 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:
  • Maintenance timing. Select the week to apply the automatic maintenance update. You have the following options:
  • Maintenance window. Select a preferred day of the week and time window. Options include the following:
  • Any window: the default maintenance window. The maintenance update is not restricted to any specific day of the week or time of day.
  • Day of the week: select a day for your maintenance window Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, or Friday. Time of day: if you select a day of the week, then you can also choose a time of day. Select a one hour interval in your local time zone.

    gcloud

    To configure a maintenance window and maintenance timing on a Cloud SQL instance, run the following command:

    gcloud sql instances patch INSTANCE_ID \
      --maintenance-window-day=DAY \
      --maintenance-window-hour=HOUR \
      --maintenance-release-channel=MAINTENANCE_TIMING
        

    Replace the following variables:

    For reference information, see gcloud sql instances patch.

    REST v1

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

    HTTP method and URL:

    PATCH https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_ID

    Request JSON body:

    {
      "settings": {
        "maintenanceWindow": {
            "hour": "HOUR",
            "day": "DAY",
            "updateTrack": "MAINTENANCE_TIMING"
        }
      }
    }
    
    

    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": "2024-04-01T21:30:35.667Z",
      "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:

    HTTP method and URL:

    PATCH https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_ID

    Request JSON body:

    {
      "settings": {
        "maintenanceWindow": {
            "hour": "HOUR",
            "day": "DAY",
            "updateTrack": "MAINTENANCE_TIMING"
        }
      }
    }
    
    

    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": "2024-04-01T21:30:35.667Z",
      "operationType": "UPDATE",
      "name": "OPERATION_ID",
      "targetId": "INSTANCE_ID",
      "selfLink": "https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/operations/OPERATION_ID",
      "targetProject": "PROJECT_ID"
    }
    

    Opt in to maintenance notifications

    Before you opt-in to receive maintenance notifications, you must set a maintenance window on an instance

    1. Go to the Communication page. Go to Communication
    2. 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:

    Find scheduled maintenance using the API

    gcloud

    To check for upcoming scheduled maintenance, use the following command:

    gcloud sql instances describe INSTANCE_ID
        

    Replace the following variable:

    In the response, look for the scheduledMaintenance section.

    REST v1

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

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/v1/projects/PROJECT_ID/instances/INSTANCE_NAME

    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"
    }
    

    In the response, look for the scheduledMaintenance section.

    REST v1beta4

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

    HTTP method and URL:

    GET https://sqladmin.googleapis.com/sql/v1beta4/projects/PROJECT_ID/instances/INSTANCE_NAME

    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"
    }
    

    In the response, look for the scheduledMaintenance section.

    Reschedule planned maintenance

    You can reschedule maintenance by using the Google Cloud console, the gcloud CLI, or the Cloud SQL Admin API.

    If you set the maintenance timing of your instance to Week 1 or Week 2, then you can reschedule maintenance by up to 28 days.

    If you set the maintenance timing of your instance to Week 5, then you can reschedule maintenance by up to 7 days. You must reschedule maintenance within this time period to ensure that the instance receives the maintenance update before the next quarterly maintenance rollout begins.

    Console

    1. In the Google Cloud console, go to the Cloud SQL Instances page.

      Go to Cloud SQL Instances

    2. Filter for the term Maintenance to list all instances scheduled for maintenance.
    3. In the Maintenance column, click Reschedule.
    4. In the Reschedule dialog, choose whether to apply maintenance immediately, reschedule it to happen at a specific time within the allowed deferral period as defined in rescheduled planned maintenance, or defer to the next available maintenance window.

    gcloud

    To reschedule maintenance on a Cloud SQL instance, run the following command:

    gcloud sql reschedule-maintenance INSTANCE_ID \
      --reschedule-type=RESCHEDULE_TYPE \
      [--schedule-time=RESCHEDULE_TIME]
      

    Replace the following variables:

    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:

    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:

    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:

    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.

    Console

    1. In the Google Cloud console, go to the Cloud SQL Instances page.

      Go to Cloud SQL Instances

    2. To open the Overview page of an instance, click the instance name.
    3. In the Maintenance section, click Edit maintenance preferences.
    4. In the Deny maintenance period section, set the start and end dates.
    5. In the Advanced options section, optionally select Repeat every year.
    6. Click Save.

    gcloud

    To configure a deny maintenance period on a Cloud SQL instance, run the following command:

    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

    Replace the following variables:

    REST v1

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

    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:

    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

    1. In the Google Cloud console, go to the Cloud SQL Instances page.

      Go to Cloud SQL Instances

    2. To open the Overview page of an instance, click the instance name.
    3. In the Maintenance section, click Edit maintenance preferences.
    4. In the Deny maintenance period section, click Clear.
    5. Click Save.

    gcloud

    To remove a deny maintenance period from a Cloud SQL instance, run the following command:

    gcloud sql instances patch INSTANCE_ID \
    --remove-deny-maintenance-period

    Replace the following variables:

    REST v1

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

    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:

    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 canceling 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.

    What's next