Restaurer une instance Cloud SQL à partir de la sauvegarde la plus récente
Suivez les instructions ci-dessous pour restaurer une instance Cloud SQL.
Console
Dans la console Google Cloud , accédez à la page Sauvegardes dans le coffre-fort.
L'utilisateur final doit disposer du rôle roles/cloudsql.admin dans le projet où se trouve l'instance cible.
L'utilisateur final doit disposer du rôle roles/backupdr.restoreUser dans le projet où se trouvent les sauvegardes sources.
Accéder aux sauvegardes stockées dans un vault
La page Sauvegardes stockées dans un vault ne liste que les ressources de données auxquelles des plans de sauvegarde ont été appliqués et dont les sauvegardes sont stockées dans un coffre de sauvegarde au sein de ce projet.
Sélectionnez la sauvegarde que vous souhaitez restaurer. Sur la page d'informations de la sauvegarde ou dans le menu more_vert, sélectionnez Restaurer.
La page Restaurer s'affiche. Vous y sélectionnez les options de restauration suivantes :
Le champ Type de ressource est prérempli avec Cloud SQL.
Dans Nom de la ressource, sélectionnez l'instance Cloud SQL à restaurer.
Lorsque vous cliquez sur Sauvegarder, un volet s'ouvre et affiche toutes les sauvegardes disponibles.
Sélectionnez la sauvegarde spécifique à restaurer.
Dans Choisir la destination de la restauration, sélectionnez le projet dans lequel vous souhaitez restaurer l'instance Cloud SQL.
Cliquez sur Continuer.
La page suivante affiche les détails de la restauration jusqu'à présent et vous invite à choisir la destination de la restauration, avec les options suivantes :
Restaurer sur une nouvelle instance : cela crée une instance basée sur la configuration stockée dans votre sauvegarde. Vous pouvez personnaliser l'instance une fois la restauration terminée. Indiquez un nouvel ID d'instance en utilisant des lettres minuscules, des chiffres et des traits d'union. Commencez par une lettre.
Écraser une instance existante : sélectionnez une instance existante à écraser dans la liste des instances disponibles.
Écraser l'instance source : cela écrasera votre instance actuelle. Toutes les données actuelles sur l'instance sélectionnée seront écrasées, y compris les journaux précédents de récupération à un moment précis. Les données écrasées ne pourront pas être récupérées. Cette méthode n'est pas recommandée pour l'utilisation en production.
gcloud
Avant de commencer
Vous devez d'abord trouver la source de données contenant la sauvegarde que vous souhaitez restaurer. Vous pouvez trouver la source de données à partir d'un projet d'instance Cloud SQL ou d'un projet de coffre-fort de sauvegarde :
Depuis le projet d'instance Cloud SQL : utilisez data-source-reference
Listez et sélectionnez la sauvegarde à restaurer. Vous devez lister toutes les sauvegardes de la source de données. Pour ce faire, utilisez la commande backups list.
Restaurer une instance Cloud SQL à un autre moment précis
Suivez les instructions ci-dessous pour restaurer une instance Cloud SQL à un moment précis. Lorsque vous restaurez une instance à un moment précis, vous créez un clone Cloud SQL.
Dans la console Google Cloud , accédez à la page Sauvegardes dans le coffre-fort.
En haut du tableau, sélectionnez Filtrer le tableau>Type de ressource.
Sélectionnez Cloud SQL. L'affichage est alors limité aux instances Cloud SQL auxquelles des plans de sauvegarde ont été appliqués et dont les sauvegardes sont stockées dans un coffre de sauvegarde au sein d'un projet.
Cliquez sur Restaurer à un moment précis.
La page Cloud SQL Créer un clone s'ouvre.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]