Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara memulihkan data dalam cadangan ke database dengan nama yang sama sebagai database sumber cadangan.
Sebelum membaca halaman ini, Anda harus sudah memahami Mencadangkan dan memulihkan data.
Pemulihan langsung
Pemulihan langsung memungkinkan Anda memulihkan database dari cadangan ke database sumber yang membuat cadangan sementara database aslinya masih ada. Pemulihan langsung membantu Anda menghindari perubahan rute traffic atau pembuatan database dengan nama yang berbeda.
Operasi pemulihan harus menggunakan database tujuan yang belum ada. Namun, Anda dapat menyimulasikan pemulihan langsung dengan menghapus database sumber dan kemudian memulihkan dari cadangan ke database baru dengan nama yang sama dengan database sumber.
Melakukan pemulihan langsung
Untuk melakukan pemulihan langsung, ikuti langkah-langkah berikut:
Identifikasi cadangan yang akan digunakan untuk operasi pemulihan.
Hapus database yang ada.
Gunakan cadangan dan ID database dari database yang dihapus untuk menyelesaikan operasi pemulihan.
Sebelum memulai
Sebaiknya selesaikan langkah-langkah berikut sebelum memulai proses pemulihan langsung:
Jika Anda perlu memulihkan database yang telah dihapus, impor data dari operasi ekspor.
Untuk memulihkan database yang dihapus ke ID database yang sama, Anda harus menunggu hingga semua operasi pemulihan yang sedang berjalan selesai, lalu:
Hapus database yang ada dengan ID database, dan tunggu minimal 5 menit
Buat database baru dengan ID database
Mulai operasi impor
Ambil dan salin konfigurasi indeks dari database Anda. Operasi ekspor tidak mengambil definisi indeks. Gunakan konfigurasi indeks untuk membuat ulang indeks setelah Anda menyelesaikan operasi pemulihan langsung. Gunakan perintah berikut untuk mengambil konfigurasi indeks database Anda:
gcloud firestore indexes fields list --database=DATABASE_ID
Melakukan pemulihan langsung
Selesaikan langkah-langkah berikut untuk melakukan operasi pemulihan langsung. Proses ini
memerlukan periode nonaktif antara saat Anda menghapus database dan ketika
operasi pemulihan selesai.
Setelah operasi pemulihan dimulai, Anda tidak dapat membatalkan operasi dan harus menunggu hingga operasi selesai. Operasi pemulihan segera menempati ID database yang digunakan dalam operasi.
Gunakan perintah gcloud alpha firestore backups list untuk mengidentifikasi cadangan yang akan digunakan untuk operasi pemulihan dan catat nama resource-nya. Nama resource menggunakan format berikut:
Tunggu setidaknya 5 menit setelah Anda menghapus database agar ID database tersedia lagi. Mulai operasi pemulihan menggunakan perintah gcloud alpha firestore databases restore:
[null,null,["Terakhir diperbarui pada 2025-08-16 UTC."],[],[],null,["\u003cbr /\u003e\n\n\n|----------------------------------------------------------------------------------------|\n| *Relevant to Cloud Firestore Standard edition and Cloud Firestore Enterprise edition.* |\n\n\u003cbr /\u003e\n\nThis page describes how to restore data in a backup to a database with the same\nname as the source database of the backup.\nBefore you read this page, you should be familiar with\n[Back up and restore data](/docs/firestore/enterprise/backups).\n\nIn-place restore\n\nAn in-place restore lets you restore a database from a backup to the\nsource database that created the backup while the original database still\nexists. An in-place restore helps you avoid rerouting traffic\nor creating a database with a different name.\n| **Warning:** Once you start the in-place restore process, the original database is permanently lost, and you can't undo this operation.\n\nA restore operation must use a destination database that\ndoesn't already exist. You can, however, simulate an in-place restore by deleting\nthe source database and then restoring from a backup to a new database with the\nsame name as the source database.\n\nPerform an in-place restore\n\nTo perform an in-place restore, follow these steps:\n\n1. Identify the backup to use for the restore operation.\n2. Delete the existing database.\n3. Use the backup and the database ID of the deleted database to complete the restore operation.\n\n| **Caution:** If your app uses a Cloud Firestore in Native mode client library and your clients use an offline cache, an in-place restore might flush your writes to the restored database instead of discarding the writes. This situation can occur if the client that is connected to the deleted database goes offline and, while offline, the cache accumulates writes at the time when you perform an in-place restore.\n\nBefore you begin\n\nWe recommend completing the following steps before starting the in-place restore\nprocess:\n\n1. [Export the data](/docs/firestore/enterprise/export-import#export_data) in the database you will delete.\n\n If you need to recover the deleted database,\n [import](/docs/firestore/enterprise/export-import#import_data) the data from export operation.\n To recover the deleted database to the same database ID, you must wait until\n any running restore operations complete and then:\n 1. Delete the existing database with the database ID and wait at least 5 minutes\n 2. Create a new database with the database ID\n 3. Start an import operation\n2. Retrieve and copy the index configuration of your database. Export operations\n do not capture index definitions. Use the index configuration to re-create\n indexes after you complete the in-place restore operation. Use the following commands\n to retrieve the index configuration of your database:\n\n - Use [`gcloud firestore indexes composite list`](https://cloud.google.com/sdk/gcloud/reference/firestore/indexes/composite/list)\n to retrieve a list of composite indexes:\n\n gcloud firestore indexes composite list --database=\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e with the ID of your database.\n - Use [`gcloud firestore indexes fields list`](https://cloud.google.com/sdk/gcloud/reference/firestore/indexes/fields/list)\n to retrieve a list of single-field (built-in) index exemptions.\n\n gcloud firestore indexes fields list --database=\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e\n\nPerform an in-place restore\n\nComplete the following steps to perform an in-place restore operation. This process\nrequires downtime between the moment you delete the database and when the\nrestore operation completes.\n\nOnce a restore operation begins, you cannot cancel the operation and must wait\nuntil the operation completes. The restore operation immediately occupies the\ndatabase ID used in the operation.\n\n1. Use the [`gcloud firestore backups list`](https://cloud.google.com/sdk/gcloud/reference/firestore/backups/list) command to identify the backup to use\n for the restore operation and note the resource name. The resource name uses\n the following format:\n\n projects/PROJECT_ID/locations/LOCATION/backups/BACKUP_ID\n\n2. Use the `gcloud firestore databases delete` command to delete the existing\n database:\n\n gcloud firestore databases delete --database='\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e'\n\n Replace \u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e with the database ID.\n3. Wait at least 5 minutes after you delete the database for the database ID\n to become available again. Initiate a restore operation using the\n [`gcloud firestore databases restore`](https://cloud.google.com/sdk/gcloud/reference/firestore/databases/restore)\n command:\n\n gcloud firestore databases restore \\\n --source-backup=projects/PROJECT_ID/locations/LOCATION/backups/BACKUP_ID \\\n --destination-database='\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e'\n\n Replace \u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e with the database ID.\n\nWhat's next\n\n- [Learn more about backup schedules and restore operations](/docs/firestore/enterprise/backups)\n- [Learn about configuring point-in-time recovery (PITR)](/docs/firestore/enterprise/pitr)"]]