[[["容易理解","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,["# Restore a Cloud SQL instance from a backup vault\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\nRestore a Cloud SQL instance from the most recent backup\n--------------------------------------------------------\n\nUse the following instructions to restore a Cloud SQL instance. \n\n### Console\n\n1. In the Google Cloud console, go to the **Vaulted backups** page.\n\n- End user should have roles/cloudsql.admin in the project where the target instance lives.\n- End user should have roles/backupdr.restoreUser in the project where the source backups exists. [Go to Vaulted backups](https://console.cloud.google.com/backupdr/vaulted-backups) The **Vaulted backups** page lists only the data resources that have backup plans applied and their backups stored in a backup vault within that project.\n\n1. Select the backup that you want to restore. Either from the backup details page for the backup, or from the more_vert menu, select **Restore**.\n\nThe **Restore page** displays where you select the following restore options:\n\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 customize 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.\n\n### gcloud\n\n### Before you begin\n\n1. You need to first find the data source that contains the backup that you\n want to restore. You can find the data source from a Cloud SQL instance\n project or a backup vault project:\n\n - From Cloud SQL instance project: Use `data-source-reference`\n\n gcloud alpha backup-dr data-source-references fetch-for-resource-type sqladmin.googleapis.com/Instance \\\n --location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003eCSQL_INSTANCE_PROJECT_ID\u003c/var\u003e \\\n --filter='dataSourceGcpResourceInfo.cloudSqlInstanceProperties.name=\"projects/\u003cvar translate=\"no\"\u003eCSQL_INSTANCE_PROJECT_ID\u003c/var\u003e/instances/\u003cvar translate=\"no\"\u003eCSQL_INSTANCE_ID\u003c/var\u003e\"' \\\n --format=\"table(RESOURCE_NAME,DATA_SOURCE)\"\n\n Replace the following: \n\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-k\"\u003eLOCATION\u003c/span\u003e\u003c/var\u003e: the location of the backup vault.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eCSQL_INSTANCE_ID\u003c/span\u003e\u003c/var\u003e: the database name of the Cloud SQL instance.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eCSQL_INSTANCE_PROJECT_ID\u003c/span\u003e\u003c/var\u003e: the project containing the Cloud SQL instance.\n\n - From a backup vault project: Use `data-source`\n\n gcloud backup-dr data-sources list \\\n --location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003eBACKUP_VAULT_PROJECT_ID\u003c/var\u003e \\\n --filter='dataSourceGcpResource.cloudSqlInstanceDatasourceProperties.name=projects/\u003cvar translate=\"no\"\u003eCSQL_INSTANCE_PROJECT_ID\u003c/var\u003e/instances/\u003cvar translate=\"no\"\u003eCSQL_INSTANCE_ID\u003c/var\u003e' \\\n --format=\"table(dataSourceGcpResource.cloudSqlInstanceDatasourceProperties.name:label=RESOURCE_NAME,name:label=DATA_SOURCE)\"\n\n Replace the following: \n\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-k\"\u003eLOCATION\u003c/span\u003e\u003c/var\u003e: the location of the backup vault.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eCSQL_INSTANCE_ID\u003c/span\u003e\u003c/var\u003e: the name of the Cloud SQL instance.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eCSQL_INSTANCE_PROJECT_ID\u003c/span\u003e\u003c/var\u003e: the project containing the Cloud SQL instance.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eBACKUP_VAULT_PROJECT_ID\u003c/span\u003e\u003c/var\u003e: the project containing the backup vault.\n\n2. List and select the backup to restore. You need to list all the backups\n in the data source. To do this, use the `backups list` command.\n\n gcloud backup-dr backups list --data-source=\u003cvar translate=\"no\"\u003eDATA_SOURCE\u003c/var\u003e \\\n --format=\"table(consistencyTime,backupType,name:label=BACKUP_NAME)\"\n\n### Restoring the backup\n\nTo restore a Cloud SQL instance using the Cloud SQL restore command,\nuse the following commands. \n\n gcloud sql backups restore \u003cvar translate=\"no\"\u003eBACKUP_NAME\u003c/var\u003e \\\n --restore-instance=\u003cvar translate=\"no\"\u003eRESTORE_INSTANCE\u003c/var\u003e \\\n --project=\u003cvar translate=\"no\"\u003eRESTORE_PROJECT\u003c/var\u003e\n\nReplace the following: \n\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eBACKUP_NAME\u003c/span\u003e\u003c/var\u003e: the backup vault name you want to restore data from.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eRESTORE_INSTANCE\u003c/span\u003e\u003c/var\u003e: The target Cloud SQL instance name.\n + \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eRESTORE_PROJECT\u003c/span\u003e\u003c/var\u003e: the project where you want to restore the Cloud SQL instance.\n\nTo override other properties, see [Overview of Backup and DR Service Google Cloud CLI commands](https://cloud.google.com/sdk/gcloud/reference/alpha/backup-dr/backups/restore).\n\nRestore a Cloud SQL instance to a different point-in-time\n---------------------------------------------------------\n\nUse the following instructions to restore a Cloud SQL instance to a point in\ntime. When you restore to a point in time, you create a Cloud SQL clone.\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. At the top of the table, select **Filter table** \\\u003e **Resource type** .\n Select **Cloud SQL**. This limits the display to only the Cloud SQL\n instances that have backup plans applied and their backups stored in a\n backup vault within a project.\n\n3. Click **Restore from a point in time** .\n The Cloud SQL **Create a clone** page opens.\n\n4. Follow the procedures in [Perform PITR by using the backup vault](/sql/docs/mysql/backup-recovery/pitr#backup-vault-pitr)."]]