Ripristina un'istanza Cloud SQL dal backup più recente
Utilizza le seguenti istruzioni per ripristinare un'istanza Cloud SQL.
Console
Nella console Google Cloud , vai alla pagina Backup protetti.
L'utente finale deve disporre dei ruoli/cloudsql.admin nel progetto in cui si trova l'istanza di destinazione.
L'utente finale deve disporre dei ruoli/backupdr.restoreUser nel progetto in cui esistono i backup di origine.
Vai a Backup archiviati nel vault
La pagina Backup archiviati nel vault elenca solo le risorse di dati a cui sono applicati piani di backup e i cui backup sono archiviati in un vault di backup all'interno di questo progetto.
Seleziona il backup che vuoi ripristinare. Dalla pagina dei dettagli
del backup o dal menu
more_vert, seleziona
Ripristina.
Nella pagina Ripristina vengono visualizzate le seguenti opzioni di ripristino:
Il campo Tipo di risorsa è precompilato con Cloud SQL.
In Nome risorsa, seleziona l'istanza Cloud SQL da ripristinare.
Quando fai clic su Backup, si apre un riquadro che mostra tutti i backup disponibili.
Seleziona il backup specifico da ripristinare.
Per Scegli la destinazione del ripristino, seleziona il progetto in cui
vuoi ripristinare l'istanza Cloud SQL.
Fai clic su Continua.
La pagina successiva mostra i dettagli del ripristino finora e ti chiede di
Scegliere la destinazione del ripristino, con queste opzioni:
Ripristina in una nuova istanza: crea una nuova istanza basata sulla configurazione memorizzata nel backup. Puoi personalizzare l'istanza al termine del ripristino. Fornisci un nuovo ID istanza utilizzando lettere minuscole, numeri e trattini. Deve iniziare con una lettera.
Sovrascrivi un'istanza esistente: seleziona un'istanza esistente da sovrascrivere dall'elenco delle istanze disponibili.
Sovrascrivi l'istanza di origine: questa operazione sovrascriverà l'istanza attuale. Tutti i dati attuali nell'istanza selezionata verranno sovrascritti, inclusi i log di recupero point-in-time precedenti. I dati sovrascritti non possono essere recuperati in un secondo momento. Questa opzione è sconsigliata per l'uso in produzione.
gcloud
Prima di iniziare
Devi prima trovare l'origine dati che contiene il backup che vuoi ripristinare. Puoi trovare l'origine dati da un progetto di istanza Cloud SQL o da un progetto del vault di backup:
Dal progetto istanza Cloud SQL: utilizza data-source-reference
Ripristina un'istanza Cloud SQL a un altro momento specifico
Utilizza le seguenti istruzioni per ripristinare un'istanza Cloud SQL a un momento specifico. Quando esegui il ripristino a un determinato momento, crei un clone Cloud SQL.
Nella console Google Cloud , vai alla pagina Backup protetti.
Nella parte superiore della tabella, seleziona Filtra tabella>Tipo di risorsa.
Seleziona Cloud SQL. In questo modo, la visualizzazione viene limitata solo alle istanze Cloud SQL a cui sono applicati piani di backup e i cui backup sono archiviati in un vault di backup all'interno di un progetto.
Fai clic su Ripristina da un momento specifico.
Si apre la pagina Crea un clone di Cloud SQL.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],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)."]]