[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Quickstart: Protect and recover a Cloud SQL instance to a backup vault\n\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nLearn how to protect and restore a Cloud SQL instance to a backup vault.\n\nIn this quickstart, you perform the following tasks:\n\n- Configure a scheduled backup for a Cloud SQL instance.\n- Back up a Cloud SQL instance into a backup vault.\n- Restore a Cloud SQL instance from a backup.\n\nBefore you begin\n----------------\n\n1. Enable the Backup and DR Service API in your Google Cloud project.\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=backupdr.googleapis.com&_ga=2.145630134.30427899.1640890668-1982243420.1634228058)\n2. [Create a backup vault](/backup-disaster-recovery/docs/cloud-console/backup-vault-create).\n Backup vaults provide protection for backups by storing them in\n secure, isolated, and specialized storage. For more information about\n backup vaults, see [Backup vault for immutable and indelible backups](/backup-disaster-recovery/docs/concepts/backup-vault).\n\n3. [Create a backup plan](/backup-disaster-recovery/docs/cloud-console/backup-plan-create).\n\nGrant a role to the backup vault service agent\n----------------------------------------------\n\nEvery backup vault created has a unique service agent linked to it.\nFor Cloud SQL instances, the service agent performs actions\non behalf of the Backup and DR Service, so it needs appropriate permissions on\nthe projects it needs to access.\n\nUse the following instructions to grant a role to the service agent.\n\n1. In the Google Cloud console, go to the **Backup vaults** page.\n\n [Go to Backup vaults](https://console.cloud.google.com/backupdr/backup-vaults/list)\n2. Click the backup vault name and copy the service agent's email address.\n\n3. In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/iam-admin/iam)\n4. In the **New principles** field, enter the service agent's email address.\n\n5. From the **Select a role** list, select the **BackupDR Cloud SQL Operator** (`roles/backupdr.cloudSqlOperator`) role.\n\n6. Click **Add another role**.\n\n7. From the **Select a role** list, select the **Service Account User** (`roles/iam.serviceAccountUser`) role.\n\n8. Click **Save**.\n\nBack up a Cloud SQL instance into a backup vault\n------------------------------------------------\n\nIn the Google Cloud console, you can back up Cloud SQL instances to a\nbackup vault by applying backup plans. You can back up in either of\nthese two ways: **Scheduled backups** and **On-demand backups**.\n\n### Configure a scheduled backup\n\nUse the following instructions to configure a scheduled backup for\nCloud SQL instances.\n\n1. In the Google Cloud console, go to the **Vaulted backups** page.\n\n [Go to Vaulted backups](https://console.cloud.google.com/backupdr/vaulted-backups)\n2. Click **Schedule backup**.\n\n3. From the **Resource Type** list, select **Cloud SQL**.\n\n4. From the **Project** list, select the project where the Cloud SQL instance\n is located.\n\n5. From the **Region** list, select the region where your instances are\n located.\n\n6. From the **Resources** list, click **Browse** . Choose the Cloud SQL\n instance that you want to back up and click **Done**.\n\n7. Click **Continue**.\n\n8. From the **Backup plan** list, click **Select**.\n\n9. Choose a backup plan that you want to protect the Cloud SQL instance with.\n\n10. Click **Done**.\n\n11. Review the backup details and click **Schedule**.\n\n As the backup window is set to six hours, you can take an on-demand backup of the Cloud SQL instance.\n | **Note:** The first backup is automatically triggered when the current time is within the backup window.\n\nTake an on-demand backup\n------------------------\n\nInitiate an on-demand backup for a Cloud SQL instance with a backup plan\nby triggering the backup rule to run immediately.\n\nUse the following instructions to create an on-demand backup.\n\n1. In the Google Cloud console, go to the **Vaulted backups** page.\n\n [Go to Vaulted backups](https://console.cloud.google.com/backupdr/vaulted-backups)\n\n The **Vaulted backups** page lists only the data resources that have\n backup plans applied and their backups stored in a backup vault\n within that project.\n2. Select the resource to back up. Either from the more_vert\n menu, or from the details page for the resource, select **Create on-demand backup**.\n\n3. In the **Create an on-demand backup** window, select a backup rule to use\n and click **Create**.\n\n4. To view the status of the on-demand backup job, click **Notifications**.\n\n | **Note:** The on-demand backup is stored in the backup vault that is configured with the associated backup plan.\n 1. In the Google Cloud console, go to the **Jobs** page to view the backup operation status.\n\n [Go to Jobs](https://console.cloud.google.com/backupdr/jobs)\n\nRestore a Cloud SQL instance from a backup\n------------------------------------------\n\nYou can restore a Cloud SQL instance to the same project or to a\ndifferent project.\n\nUse the following instructions to restore a Cloud SQL instance into a\nbackup vault from a backup.\n\n1. In the Google Cloud console, go to the **Vaulted backups** page.\n\n [Go to Vaulted backups](https://console.cloud.google.com/backupdr/vaulted-backups)\n\n The **Vaulted backups** page lists only the instances that have\n backup plans applied and their backups stored in a backup vault\n within a project.\n2. Select the backup that you want to restore. Either from the backup\n details page for the backup, or from the\n more_vert menu, select\n **Restore**.\n\n The **Restore page** displays where you select the following restore options:\n - The **Resource type** is prefilled with `Cloud SQL`.\n - In **Resource name**, select the Cloud SQL instance to restore.\n - When you click **Backup**, a pane opens showing all available backups. Select the specific backup to restore.\n - For **Choose the restore destination**, select the project into which you want to restore the Cloud SQL instance.\n - Click **Continue**.\n - The next page shows the restore details so far, and prompts you to\n **Choose restore destination**, with these options:\n\n - **Restore to a new instance** : This creates a new instance based on the configuration stored in your backup. You can customise the instance after the restore is complete. Provide a new **Instance ID** using lowercase letters, numbers, and hyphens. Start with a letter.\n - **Overwrite an existing instance**: Select an existing instance to overwrite from the list of available instances.\n - **Overwrite the source instance**: This will overwrite your current instance. All the current data on the selected instance will be overwritten, including previous point-in-time recovery logs. The overwritten data cannot be recovered later. This is not recommended for production use.\n3. In the Google Cloud console, go to the **Jobs** page to view the restore\n operation status.\n\n [Go to Jobs](https://console.cloud.google.com/backupdr/jobs)\n\nClean up\n--------\n\nTo avoid incurring charges to your Google Cloud account, remember to delete the\nresources used on this page if you have no further use for them.\n\nUse the following instructions to remove the backup plan from the backed up Cloud SQL instance.\n\n1. In the Google Cloud console, go to the **Vaulted resources** page.\n\n [Go to Vaulted resources](https://console.cloud.google.com/backupdr/vaulted-resources)\n2. Select the backed up instance.\n\n3. Click **Remove backup plan**.\n\n | **Note:** The backup automatically expires and gets deleted after the retention period that you set.\n\nUse the following instructions to delete the backup plan. Deleting the backup plan is an optional step.\n\n1. In the Google Cloud console, go to the **Backup plans** page.\n\n [Go to Backup plans](https://console.cloud.google.com/backupdr/backup-plans/list)\n2. Select the backup plan and click **Delete**.\n\n This deletes the backup plan and related contents.\n\nUse the following instructions to delete the backup vault. Deleting the backup vault is an optional step.\n\n1. In the Google Cloud console, go to the **Backup vaults** page.\n\n [Go to Backup vaults](https://console.cloud.google.com/backupdr/backup-vaults/list)\n2. Click the backup vault and click **Delete**.\n\n This deletes the backup vault and related contents.\n | **Note:** The backup vault incurs a cost only when the backup vault stores data. The existence of a backup plan doesn't incur any cost."]]