Questa pagina descrive come elencare e ripristinare un bucket eliminato temporaneamente.
Panoramica
Dopo l'eliminazione temporanea di un bucket, questo viene conservato da Cloud Storage fino al momento dell'eliminazione definitiva e non può essere modificato mentre si trova in uno stato di eliminazione temporanea. La data/ora di eliminazione definitiva è almeno pari alla data/ora di eliminazione definitiva più recente degli oggetti del bucket. Trascorso il tempo di eliminazione definitiva, Cloud Storage elimina definitivamente il bucket. Quando ripristini un bucket eliminato temporaneamente, questo torna allo stato attivo e anche gli oggetti che si trovavano nel bucket al momento dell'eliminazione possono essere ripristinati.
Considerazioni
Per proteggere da eliminazioni dannose, un bucket eliminato temporaneamente non può
essere eliminato definitivamente finché non è stato conservato per l'intera
durata di conservazione dell'eliminazione temporanea.
Una volta che un bucket è stato eliminato temporaneamente, devi ripristinarlo prima di poter elencare o ripristinare gli oggetti eliminati temporaneamente al suo interno.
Per ripristinare un bucket eliminato temporaneamente, devi disporre del numero di generazione del bucket. Per recuperare il numero di generazione di un bucket eliminato temporaneamente,
consulta Elenca i bucket eliminati temporaneamente.
Un bucket eliminato temporaneamente può essere ripristinato solo se non esiste
un bucket attivo con lo stesso nome. Se tu o qualcun altro create un bucket
con lo stesso nome di un bucket eliminato temporaneamente, non potete ripristinare il
bucket eliminato temporaneamente finché il nuovo bucket non viene eliminato.
Le operazioni di ripristino del bucket non ripristinano gli oggetti eliminati temporaneamente che si trovavano
nel bucket al momento dell'eliminazione. Per ripristinare gli oggetti eliminati temporaneamente dopo il ripristino del bucket eliminato temporaneamente, devi eseguire un'operazione di ripristino degli oggetti.
I binding dei tag potrebbero non essere recuperati quando ripristini un bucket eliminato temporaneamente
con i tag. Per evitare perdite di dati, quando ripristini un bucket eliminato temporaneamente con
associazione di tag, ti consigliamo di verificare che le associazioni di tag del bucket siano state
recuperate. Se i binding dei tag del bucket non sono stati recuperati, dovrai
associare manualmente i tag non recuperati al bucket.
Autorizzazioni obbligatorie
Per ottenere le autorizzazioni
necessarie per ripristinare i bucket eliminati temporaneamente,
chiedi all'amministratore di concederti il
ruolo IAM Storage Admin (roles/storage.admin)
nel progetto Cloud Storage.
Questo ruolo predefinito contiene
le autorizzazioni necessarie per ripristinare i bucket eliminati temporaneamente. Per vedere quali sono esattamente le autorizzazioni richieste, espandi la sezione Autorizzazioni obbligatorie:
Autorizzazioni obbligatorie
Per ripristinare i bucket eliminati temporaneamente sono necessarie le seguenti autorizzazioni:
storage.buckets.list
storage.buckets.restore
Elenca i bucket eliminati temporaneamente
Puoi eseguire operazioni di elenco per recuperare i metadati dei bucket eliminati temporaneamente.
Utilizza le seguenti istruzioni per elencare tutti i bucket eliminati temporaneamente nel tuo progetto:
Riga di comando
Per elencare tutti i bucket eliminati temporaneamente, utilizza il comando
gcloud storage ls:
BUCKET_NAME: il nome del bucket eliminato temporaneamente
che vuoi ripristinare.
GENERATION_NUMBER: il numero di generazione permanente e univoco del bucket eliminato temporaneamente che vuoi ripristinare.
Per ottenere il numero di generazione del bucket, consulta
Elenco dei bucket eliminati temporaneamente.
BUCKET_NAME è il nome del bucket
che vuoi ripristinare. Ad esempio, my-bucket.
GENERATION_NUMBER è il numero di generazione univoco e permanente del bucket eliminato temporaneamente che vuoi ripristinare. Per ottenere il numero di generazione del bucket, consulta
Elenco dei bucket eliminati temporaneamente.
Cloud Storage ripristina il bucket eliminato temporaneamente a uno stato attivo. Tieni presente che
il ripristino del bucket non ripristina gli oggetti che si trovavano nel bucket al momento dell'eliminazione temporanea. Per ripristinare gli oggetti eliminati temporaneamente che si trovavano nel
bucket al momento dell'eliminazione, consulta Ripristinare un oggetto eliminato temporaneamente.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 UTC."],[],[],null,["# Use soft-deleted buckets\n\n[Soft delete feature overview](/storage/docs/soft-delete)\n\nThis page describes how to list and restore a soft-deleted bucket.\n\nOverview\n--------\n\nAfter a bucket is soft-deleted, it's retained by Cloud Storage until its\nhard delete time, and cannot be modified while in a soft-deleted state. The hard\ndelete time is at least as long as the latest hard delete time of the bucket's\nobjects. After the hard delete time has elapsed, Cloud Storage permanently\ndeletes the bucket. When you restore a soft-deleted bucket, it is returned to a\nlive state, and objects that were in the bucket at the time of deletion can also\nbe restored.\n\nConsiderations\n--------------\n\n- To protect against malicious deletion, a soft-deleted bucket cannot\n be permanently deleted until the bucket has been retained for its full\n soft delete retention duration.\n\n- Once a bucket is a soft-deleted, you must restore the bucket before you\n can list or restore the soft-deleted objects in it.\n\n- To restore a soft-deleted bucket, you must have the bucket's\n generation number. To retrieve a soft-deleted bucket's generation number,\n see [List soft-deleted buckets](#list-soft-deleted-buckets).\n\n- A soft-deleted bucket can only be restored if there is no\n live bucket with the same name. If you or anyone else creates a bucket\n with the same name as a soft-deleted bucket, you cannot restore the\n soft-deleted bucket until the new bucket is deleted.\n\n- Bucket restore operations don't restore the soft-deleted objects that were\n in the bucket at the time of deletion. To restore soft-deleted objects after\n the soft-deleted bucket has been restored, you'll need to perform an object\n restore operation.\n\n- Tag bindings might not be recovered when you restore a soft-deleted bucket\n with tags. To avoid data loss, when you restore a soft-deleted bucket with\n tag bindings, we recommend checking to ensure the bucket's tag bindings were\n recovered. If the bucket's tag bindings weren't recovered, you'll need to\n [manually bind the unrecovered tags to the bucket](/resource-manager/docs/tags/tags-creating-and-managing#attaching).\n\nRequired permissions\n--------------------\n\n\nTo get the permissions that\nyou need to restore soft-deleted buckets,\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 Cloud Storage project.\n\n\nThis predefined role contains\n\nthe permissions required to restore soft-deleted buckets. 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 restore soft-deleted buckets:\n\n- `storage.buckets.list`\n- `storage.buckets.restore`\n\nList soft-deleted buckets\n-------------------------\n\nYou can perform list operations to retrieve your soft-deleted buckets'\nmetadata.\n| **Note:** A bucket cannot be listed if its hard delete time has elapsed.\n\nUse the following instructions to list all soft-deleted buckets in your project: \n\n### Command line\n\nTo list all soft-deleted buckets, use the\n[`gcloud storage ls`](/sdk/gcloud/reference/storage/buckets/list) command: \n\n```\ngcloud storage ls --buckets --soft-deleted --full\n```\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/list) request:\n\n```\ncurl -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?softDeleted=true\"\n```\n\nRestore a soft-deleted bucket\n-----------------------------\n\nUse the following instructions to restore a soft-deleted bucket: \n\n### Command line\n\nTo restore a soft-deleted bucket, use the [`gcloud storage restore`](/sdk/gcloud/reference/storage/restore)\ncommand: \n\n```\n gcloud storage restore gs://BUCKET_NAME#GENERATION_NUMBER\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e: the name of the soft-deleted\n bucket you want to restore.\n\n- \u003cvar translate=\"no\"\u003eGENERATION_NUMBER\u003c/var\u003e: the permanent, unique\n generation number of the soft-deleted bucket you want to restore.\n To get your bucket's generation number, see\n [List soft-deleted buckets](#list-soft-deleted-buckets).\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 [`POST` Bucket](/storage/docs/json_api/v1/buckets/restore) request: \n\n ```\n curl -X POST \\\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/restore?generation=GENERATION_NUMBER\n ```\n\n Where:\n - \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the bucket\n you want to restore. For example, `my-bucket`.\n\n - \u003cvar translate=\"no\"\u003eGENERATION_NUMBER\u003c/var\u003e is the permanent,\n unique generation number of the soft-deleted bucket you want\n to restore. To get your bucket's generation number, see\n [List soft-deleted buckets](#list-soft-deleted-buckets).\n\nCloud Storage restores the soft-deleted bucket to a live state. Note that\nrestoring the bucket doesn't restore the objects that were in the bucket at the\ntime of soft deletion. To restore the soft-deleted objects that were in the\nbucket at the time of deletion, see [Restore a soft-deleted object](/storage/docs/use-soft-deleted-objects#restore).\n\nWhat's next\n-----------\n\n- [Restore soft-deleted objects in your bucket](/storage/docs/use-soft-deleted-objects#restore)."]]