Auf dieser Seite wird beschrieben, wie Sie Richtlinien zum vorläufigen Löschen festlegen und verwalten.
Sie können neue Richtlinien für Buckets festlegen, um das vorläufige Löschen zu aktivieren, sowie vorhandene Richtlinien aktualisieren und den Status vorhandener Richtlinien prüfen. Informationen zum Deaktivieren des vorläufigen Löschens finden Sie unter Vorläufiges Löschen deaktivieren.
Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Storage-Administrator (roles/storage.admin) für den Bucket oder das Projekt, das den Bucket enthält, zuzuweisen, um die Berechtigungen zu erhalten, die Sie zum Aktivieren und Verwalten von Richtlinien zum vorläufigen Löschen benötigen.
Diese vordefinierte Rolle enthält die Berechtigungen, die zum Aktivieren und Verwalten von Richtlinien zum vorläufigen Löschen erforderlich sind. Erweitern Sie den Abschnitt Erforderliche Berechtigungen, um die erforderlichen Berechtigungen anzuzeigen:
Erforderliche Berechtigungen
Die folgenden Berechtigungen sind erforderlich, um Richtlinien für das vorläufige Löschen zu aktivieren und zu verwalten:
storage.buckets.get
storage.buckets.update
storage.buckets.list (ist nur erforderlich, wenn Sie die Google Cloud Console zum Ausführen der Anleitung auf dieser Seite verwenden möchten)
Richtlinie für vorläufiges Löschen eines Buckets bearbeiten
Die neue Aufbewahrungsdauer für das vorläufige Löschen gilt nur für Objekte oder Buckets, die Sie nach Inkrafttreten der Richtlinie für das vorläufige Löschen löschen. Vorhandene vorläufig gelöschte Objekte sind von Aktualisierungen der Richtlinie für vorläufiges Löschen nicht betroffen und werden für die Dauer beibehalten, die beim Löschen gegolten hat.
So bearbeiten Sie die Richtlinie für das vorläufige Löschen eines Buckets:
Konsole
Wechseln Sie in der Google Cloud Console unter „Cloud Storage“ zur Seite Buckets.
Klicken Sie in der Liste der Buckets auf den Namen des Buckets, dessen Richtlinie für das vorläufige Löschen Sie bearbeiten möchten.
Klicken Sie auf den Tab Schutz.
Führen Sie im Abschnitt Richtlinie für vorläufiges Löschen (zur Datenwiederherstellung) die folgenden Schritte aus, um eine neue Richtlinie für vorläufiges Löschen hinzuzufügen oder die Aufbewahrungsdauer einer vorhandenen Richtlinie zu bearbeiten:
Klicken Sie auf Bearbeiten.
Geben Sie im angezeigten Dialogfeld Richtlinie für vorläufiges Löschen festlegen eine Aufbewahrungsdauer für vorläufiges Löschen an, indem Sie eine Zeiteinheit und eine Zeitspanne auswählen.
Klicken Sie auf Speichern.
Unter Fehlerbehebung erfahren Sie, wie Sie detaillierte Fehlerinformationen zu fehlgeschlagenen Cloud Storage-Vorgängen in der Google Cloud Console abrufen.
Befehlszeile
Verwenden Sie den Befehl gcloud storage buckets update mit dem Flag --soft-delete-duration, um die Richtlinie für das vorläufige Löschen für einen Bucket hinzuzufügen oder zu bearbeiten:
Klicken Sie in der Liste der Buckets auf den Namen des Buckets, dessen Richtlinie für das vorläufige Löschen Sie prüfen möchten.
Klicken Sie auf den Tab Schutz.
Der Status wird im Abschnitt Richtlinie für vorläufiges Löschen (zur Datenwiederherstellung) angezeigt.
Auf dem Tab Schutz können Sie auch prüfen, ob für Ihren Bucket eine Richtlinie für das vorläufige Löschen gilt.
Unter Fehlerbehebung erfahren Sie, wie Sie detaillierte Fehlerinformationen zu fehlgeschlagenen Cloud Storage-Vorgängen in der Google Cloud Console abrufen.
Befehlszeile
Verwenden Sie den Befehl gcloud storage buckets describe, um den Status der Richtlinie für das vorläufige Löschen eines Buckets zu prüfen:
[[["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-05 (UTC)."],[],[],null,["# Set and manage soft delete policies\n\n[Overview](/storage/docs/soft-delete)\n[Usage](/storage/docs/use-soft-deleted-objects)\n\nThis page describes how to set and manage [soft delete policies](/storage/docs/soft-delete#soft-delete-policy).\nYou can set new policies on buckets to enable soft delete, as well as\nupdate and check the status of existing policies. To learn how to disable\nsoft delete, see [Disable soft delete](/storage/docs/disable-soft-delete).\n\nTo learn how to list and restore soft-deleted objects, see\n[Use soft-deleted objects](/storage/docs/use-soft-deleted-objects). To learn how to list and restore\nsoft-deleted buckets, see [Use soft-deleted buckets](/storage/docs/use-soft-deleted-buckets).\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to enable and manage soft delete policies,\n\nask your administrator to grant you the\n\n\n[Storage Admin](/iam/docs/roles-permissions/storage#storage.admin) (`roles/storage.admin`)\nIAM role on the bucket or the project that contains the bucket.\n\n\nThis predefined role contains\n\nthe permissions required to enable and manage soft delete policies. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to enable and manage soft delete policies:\n\n- `storage.buckets.get`\n- `storage.buckets.update`\n- `storage.buckets.list` (this permission is only required if you plan to use the Google Cloud console to perform the instructions on this page)\n\nFor information about granting roles, see\n[Use IAM with buckets](/storage/docs/access-control/using-iam-permissions#bucket-iam) or [Manage access to projects](/iam/docs/granting-changing-revoking-access).\n\nEdit a bucket's soft delete policy\n----------------------------------\n\nThe new soft delete retention duration only\napplies to objects or buckets that you delete after the\nsoft delete policy takes effect. Existing soft-deleted objects aren't\naffected by updates made to the soft delete policy and are retained\nfor the duration that was in effect when they were deleted.\n\nUse the following instructions to edit a bucket's soft delete\npolicy: \n\n### Console\n\n1. In the Google Cloud console, go to the Cloud Storage **Buckets** page. \n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n2. In the list of buckets, click the name of the bucket whose\n soft delete policy you want to edit.\n\n3. Click the **Protection** tab.\n\n4. In the **Soft delete policy (for data recovery)** section, add a new\n soft delete policy or edit the [retention duration](/storage/docs/soft-delete#retention-duration) of\n an existing policy by using the following steps:\n\n 1. Click **Edit**.\n\n 2. In the **Set a soft delete policy** dialogue that appears, specify\n a [soft delete retention duration](/storage/docs/soft-delete#retention-duration) by choosing a unit\n of time and a length of time.\n\n 3. Click **Save**.\n\nTo learn how to get detailed error information about failed Cloud Storage\noperations in the Google Cloud console, see\n[Troubleshooting](/storage/docs/troubleshooting#trouble-console).\n\n### Command line\n\nTo add or edit the soft delete policy on a bucket, use the\n[`gcloud storage buckets update`](/sdk/gcloud/reference/storage/buckets#update) command with the\n`--soft-delete-duration` flag: \n\n```\n gcloud storage buckets update gs://BUCKET_NAME --soft-delete-duration=SOFT_DELETE_DURATION\n```\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the bucket. For\n example, `my-bucket`.\n\n- \u003cvar translate=\"no\"\u003eSOFT_DELETE_DURATION\u003c/var\u003e specifies the\n [soft delete retention duration](/storage/docs/soft-delete#retention-duration).\n\n - The unit `s` represents seconds.\n - The unit `d` represents days.\n - The unit `m` represents months.\n\n For example:\n - `7d43200s` sets a retention duration of seven and a half days\n (7 days and 43,200 seconds).\n\n - `2w1d` sets a retention duration of two weeks and one day.\n\n### REST APIs\n\n### JSON API\n\n1. Have gcloud CLI [installed and initialized](/sdk/docs/install), which lets\n you generate an access token for the `Authorization` header.\n\n\n2. Create a JSON file that contains the following information:\n\n\n ```json\n {\n \"softDeletePolicy\": {\n \"retentionDurationSeconds\": \"\u003cvar translate=\"no\"\u003eTIME_IN_SECONDS\u003c/var\u003e\"\n }\n }\n ```\n\n\n Where \u003cvar translate=\"no\"\u003eTIME_IN_SECONDS\u003c/var\u003e is the amount of\n time in seconds you want to set the\n [soft delete retention duration](/storage/docs/soft-delete#retention-duration) to. For\n example, `2678400` for 2,678,400 seconds (31 days).\n3. Use [`cURL`](http://curl.haxx.se/) to call the [JSON API](/storage/docs/json_api) with a\n [`PATCH` Bucket](/storage/docs/json_api/v1/buckets/patch) request:\n\n ```\n curl -X PATCH --data-binary @JSON_FILE_NAME \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME\"\n ```\n\n Where:\n - \u003cvar translate=\"no\"\u003eJSON_FILE_NAME\u003c/var\u003e is the path for the JSON file that you created in Step 2.\n - \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the relevant bucket. For example, `my-bucket`.\n\nCheck if the soft delete policy is enabled on a bucket\n------------------------------------------------------\n\n### Console\n\n1. In the Google Cloud console, go to the Cloud Storage **Buckets** page. \n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n2. In the list of buckets, click the name of the bucket whose\n soft delete policy you want to check.\n\n3. Click the **Protection** tab.\n\n The status displays in the **Soft delete policy (for data recovery)**\n section.\n\nYou can also use the **Protection tab** to check if there's a\nsoft delete policy on your bucket.\n\nTo learn how to get detailed error information about failed Cloud Storage\noperations in the Google Cloud console, see\n[Troubleshooting](/storage/docs/troubleshooting#trouble-console).\n\n### Command line\n\nTo check the soft delete policy status of a bucket, use the\n[`gcloud storage buckets describe`](/sdk/gcloud/reference/storage/buckets/describe) command: \n\n```\n gcloud storage buckets describe gs://BUCKET_NAME \\\n --format=\"default(soft_delete_policy)\"\n```\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the bucket. For example, `my-bucket`.\n\n### REST APIs\n\n### JSON API\n\n1. Have gcloud CLI [installed and initialized](/sdk/docs/install), which lets\n you generate an access token for the `Authorization` header.\n\n\n2.\n\n Use [`cURL`](http://curl.haxx.se/) to call the [JSON API](/storage/docs/json_api) with a\n [`GET` Bucket](/storage/docs/json_api/v1/buckets/get) request: \n\n ```\n curl -X GET \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=softDeletePolicy\"\n ```\n\n Where \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the\n relevant bucket. For example, `my-bucket`.\n\nWhat's next\n-----------\n\n- Learn how to [use soft-deleted objects](/storage/docs/use-soft-deleted-objects).\n- Learn how to [use soft-deleted buckets](/storage/docs/use-soft-deleted-buckets).\n- Learn how to [disable soft delete](/storage/docs/disable-soft-delete)."]]