Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Direkte Wiederherstellung ausführen
Auf dieser Seite wird beschrieben, wie Sie Daten in einer Sicherung in einer Datenbank mit demselben Namen wie die Quelldatenbank der Sicherung wiederherstellen.
Bevor Sie diese Seite lesen, sollten Sie sich mit Daten sichern und wiederherstellen vertraut gemacht haben.
Direkte Wiederherstellung
Bei einer direkten Wiederherstellung können Sie eine Datenbank aus einer Sicherung in der Quelldatenbank wiederherstellen, in der die Sicherung erstellt wurde, während die ursprüngliche Datenbank weiterhin vorhanden ist. Mit einer In-Place-Wiederherstellung können Sie vermeiden, dass der Traffic umgeleitet oder eine Datenbank mit einem anderen Namen erstellt werden muss.
Für einen Wiederherstellungsvorgang muss eine Zieldatenbank verwendet werden, die noch nicht vorhanden ist. Sie können jedoch eine In-Place-Wiederherstellung simulieren, indem Sie die Quelldatenbank löschen und dann aus einer Sicherung in eine neue Datenbank mit demselben Namen wie die Quelldatenbank wiederherstellen.
Direkte Wiederherstellung durchführen
So führen Sie eine In-Place-Wiederherstellung durch:
Wählen Sie die Sicherung aus, die für den Wiederherstellungsvorgang verwendet werden soll.
Löschen Sie die vorhandene Datenbank.
Verwenden Sie die Sicherung und die Datenbank-ID der gelöschten Datenbank, um den Wiederherstellungsvorgang abzuschließen.
Hinweise
Wir empfehlen, die folgenden Schritte auszuführen, bevor Sie mit der In-Place-Wiederherstellung beginnen:
Wenn Sie die gelöschte Datenbank wiederherstellen müssen, importieren Sie die Daten aus dem Exportvorgang.
Wenn Sie die gelöschte Datenbank mit derselben Datenbank-ID wiederherstellen möchten, müssen Sie warten, bis alle laufenden Wiederherstellungsvorgänge abgeschlossen sind, und dann Folgendes tun:
Löschen Sie die vorhandene Datenbank mit der Datenbank-ID und warten Sie mindestens 5 Minuten.
Neue Datenbank mit der Datenbank-ID erstellen
Importvorgang starten
Rufen Sie die Indexkonfiguration Ihrer Datenbank ab und kopieren Sie sie. Bei Exportvorgängen werden keine Indexdefinitionen erfasst. Verwenden Sie die Indexkonfiguration, um Indexe neu zu erstellen, nachdem Sie den In-Place-Wiederherstellungsvorgang abgeschlossen haben. Verwenden Sie die folgenden Befehle, um die Indexkonfiguration Ihrer Datenbank abzurufen:
gcloud firestore indexes fields list --database=DATABASE_ID
Direkte Wiederherstellung durchführen
So führen Sie eine In-Place-Wiederherstellung durch: Bei diesem Vorgang ist eine Ausfallzeit zwischen dem Löschen der Datenbank und dem Abschluss des Wiederherstellungsvorgangs erforderlich.
Sobald ein Wiederherstellungsvorgang gestartet wurde, können Sie ihn nicht mehr abbrechen. Sie müssen warten, bis er abgeschlossen ist. Die Datenbank-ID, die im Vorgang verwendet wird, wird sofort für den Wiederherstellungsvorgang belegt.
Verwenden Sie den Befehl gcloud firestore backups list, um die Sicherung zu identifizieren, die für den Wiederherstellungsvorgang verwendet werden soll, und notieren Sie sich den Ressourcennamen. Der Ressourcenname hat das folgende Format:
Warten Sie nach dem Löschen der Datenbank mindestens 5 Minuten, bis die Datenbank-ID wieder verfügbar ist. Starten Sie einen Wiederherstellungsvorgang mit dem Befehl gcloud firestore databases restore:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[],[],null,["# Perform an in-place restore operation\n=====================================\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](/firestore/mongodb-compatibility/docs/backups).\n\nIn-place restore\n----------------\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\n### Perform 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 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\n### Before you begin\n\nWe recommend completing the following steps before starting the in-place restore\nprocess:\n\n1. [Export the data](/firestore/mongodb-compatibility/docs/export-import#export_data) in the database you will delete.\n\n If you need to recover the deleted database,\n [import](/firestore/mongodb-compatibility/docs/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\n### Perform 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\n- [Learn more about backup schedules and restore operations](/firestore/mongodb-compatibility/docs/backups)\n- [Learn about configuring point-in-time recovery (PITR)](/firestore/mongodb-compatibility/docs/pitr)"]]