[[["容易理解","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-05 (世界標準時間)。"],[],[],null,["# Restore overview\n\nYou can restore a backup of a Spanner database into a new database. The\nrestored database will have all the data and schema from the original database\nat the `version_time` of the backup, including all database options that are set\nwith the [`ALTER DATABASE SET OPTIONS`](/spanner/docs/reference/standard-sql/data-definition-language#alter-database)\ncommand. However, the following aren't included in the restored database:\n\n- IAM permissions (except for those inherited from the instance containing the restored database). You must apply appropriate IAM permissions after the restore completes.\n- Internal data of any change streams.\n- Time to live (TTL) defined by a row deletion policy. You must reconfigure these policies after the restore completes. For more information, see [Backups and TTL](/spanner/docs/ttl#backups).\n- Split points you created when pre-splitting a database. For more information, see [Pre-splitting overview](/spanner/docs/pre-splitting-overview).\n\nWhen you restore from a backup, the restored database resides in the same\ninstance, region, and project as its source backup. If you need to restore from\nthe backup in a different region or project for compliance or business\ncontinuity reasons, you can\n[copy the backup](/spanner/docs/backup/manage-backups#copy-backup) to an\ninstance in a separate region or project, then restore from the copied backup.\n\nYou can use restore from a backup in the following ways:\n\n- In the [Google Cloud console](/spanner/docs/backup/gcp#restore)\n- Using the [Google Cloud CLI](/spanner/docs/backup/gcloud#restore)\n- Using the [client libraries](/spanner/docs/backup/libraries#restore)\n- Using the [REST](/spanner/docs/reference/rest/v1/projects.instances.backups#restore) or [RPC](/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.Backup) APIs\n\nHow database restoration from a backup works\n--------------------------------------------\n\nWhen you restore a Spanner database, you must specify a source\nbackup and a new target database. You cannot restore to an existing database.\nThe newly restored database must be in the same project as the backup and be in\nan instance with the same\n[instance configuration](/spanner/docs/instances#configuration) and same (or\nhigher-tier) [Spanner edition](/spanner/docs/editions-overview) as\nthe backup. For example, if a backup is in an instance configured `us-west3` and\nuses the Enterprise edition, it can be restored to any instance in the\nproject that is also configured `us-west3` and uses the\nEnterprise edition. If you restore a backup in an\nEnterprise edition instance into a Standard edition\ninstance, the restore might fail if the database uses\nEnterprise edition features. The [compute capacity](/spanner/docs/compute-capacity) of the\ninstances doesn't need to be the same.\n\nThe restore process is designed for high-availability. The database can be\nrestored provided that the majority quorum of the regions and zones in the\ninstance is available.\n\nTo restore a CMEK-enabled backup, both the key and key version must be available\nto Spanner. The restored database, by default, uses the same\n[encryption configurations](/spanner/docs/reference/rest/v1/projects.instances.databases/restore#RestoreDatabaseEncryptionConfig)\nas the backup. You can override this behavior by specifying a different\nencryption configuration when restoring the database. For more information, see\n[restore from a CMEK-enabled backup](/spanner/docs/use-cmek#restore).\n| **Note:** Before restoring a database, make sure your instance is properly provisioned with enough storage and compute capacity to handle the additional storage and traffic associated with the restored database. If the target instance is not properly provisioned, restoring a database could adversely affect the performance of existing databases in the instance.\n\n### Restore a backup to a different region or project\n\nIf you need to restore the backup to a different region or project, first,\n[copy the backup](/spanner/docs/backup/manage-backups#copy-backup) to the\nchosen region or project. Copied backups are restorable as soon as the copy\nfinishes. You can restore the backup either in the destination instance (as long\nas it uses the edition as the source backup instance) or in any instance that\nhas the same instance configuration and same (or higher-tier) edition as the\ndestination instance. Before restoring, make sure that the destination instance\nhas enough nodes or processing units provisioned to support the database size\naccording to the 10 TB per node storage limit (that is, you need at least 2\nnodes to restore a 20 TB backup). If you have copied the backup to a different\nproject, and if you want to restore it there, make sure that your destination\nproject has enough node quotas required for the restore. Restoring a copied\nbackup works the same way as a normal restore.\n\nRestoration states\n------------------\n\nA restored database transitions through three [states](/spanner/docs/reference/rest/v1/projects.instances.databases#state),\ntracked by two [long-running operations](/spanner/docs/manage-long-running-operations).\n\n- `CREATING`: Spanner begins restoring by creating a new\n database and mounting files from the backup. During this initial `CREATING`\n state, the restored database is not yet ready for use. This state typically\n completes within one hour. Once the `CREATING` state is complete, your\n database is ready to use.\n\n To track the progress of this state, you can query the [long-running restore\n operation](/spanner/docs/manage-long-running-operations) that\n Spanner makes available during this process. It returns a\n [`RestoreDatabaseMetadata`](/spanner/docs/reference/rest/v1/RestoreDatabaseMetadata) object.\n\n Note the following caveats regarding the `CREATING` state:\n - If you are restoring to a different instance, the restore operation belongs to the instance containing the restored database, not the instance containing the backup.\n - Spanner won't allow you to delete the backup while it is being restored. You can delete it after the restore completes and the database enters the `READY` state.\n - An instance can have at most ten databases in the `CREATING` state due to restoration from backups. You won't be able to restore another backup to the instance until one of the ten restored databases transitions to the `READY_OPTIMIZING` or `READY` state.\n- `READY_OPTIMIZING`: After Spanner mounts the backup, it starts\n to copy the backup data into the new database while optimizing its stored\n size. Your database is ready for use during this process. This phase of the\n restore usually takes a few hours to complete for databases less than 100TB\n in size.\n\n While you can use your database as usual during `READY_OPTIMIZING`, the\n following caveats apply:\n - Read latencies might be slightly higher than usual.\n - [Storage metrics](/spanner/docs/storage-utilization) display the size of the new database, not the backup. Therefore, with the data transfer still in progress, Spanner storage metrics might show results that don't reflect the total size of all your data.\n - As with the `CREATING` state, Spanner won't allow you to delete the mounted backup.\n\n Spanner makes another [long-running restore operation](/spanner/docs/manage-long-running-operations)\n available during this state, this time returning a [`OptimizeRestoredDatabaseMetadata`](/spanner/docs/reference/rest/v1/OptimizeRestoredDatabaseMetadata)\n metadata object.\n- `READY`: Once the copy-and-optimize operation completes, the database\n transitions to the `READY` state. The database is fully restored, and no\n longer references or requires the backup.\n\nAccess control (IAM)\n--------------------\n\nThe role `spanner.restoreAdmin` gives you permission to restore from a backup.\nFor more information, see [Access control with IAM](/spanner/docs/backup#iam).\n\nThe following roles also have access to Spanner restore operations:\n\n- `spanner.admin`: has full access to restore. This role has complete access to all Spanner resources.\n- `owner`: has full access to restore.\n- `editor`: has full access to restore.\n- `viewer`: has access to view restore and restore operations. This role can't create, update, delete, or copy a backup.\n\nPricing\n-------\n\nThere is no charge for restoring from a backup.\n\nWhat's next\n-----------\n\n- To restore a database from a backup, see [Restore from a backup](/spanner/docs/backup/restore-backups)."]]