Nesta página, descrevemos como listar e restaurar um bucket excluído de maneira reversível.
Visão geral
Depois que um bucket é excluído de maneira reversível, ele é mantido pelo Cloud Storage até o momento da exclusão permanente e não pode ser modificado enquanto está nesse estado. O tempo de exclusão
irreversível é pelo menos tão longo quanto o tempo de exclusão irreversível mais recente dos objetos do bucket. Depois que o tempo de exclusão permanente expirar, o Cloud Storage vai excluir o bucket permanentemente. Quando você restaura um bucket excluído de maneira reversível, ele volta a um estado
ativo, e os objetos que estavam nele no momento da exclusão também podem
ser restaurados.
Considerações
Para proteção contra exclusão maliciosa, um bucket excluído de forma reversível não pode
ser excluído permanentemente até que ele seja retido por toda a duração
da retenção da exclusão reversível.
Depois que um bucket é excluído de forma reversível, é necessário restaurá-lo antes de
listar ou restaurar os objetos excluídos de forma reversível nele.
Para restaurar um bucket excluído de maneira reversível, você precisa ter o número de geração dele. Para recuperar o número de geração de um bucket excluído de maneira reversível,
consulte Listar buckets excluídos de maneira reversível.
Um bucket excluído de maneira reversível só pode ser restaurado se não houver um bucket ativo com o mesmo nome. Se você ou outra pessoa criar um bucket
com o mesmo nome de um que foi excluído de maneira reversível, não será possível restaurá-lo
até que o novo seja excluído.
As operações de restauração de bucket não restauram os objetos excluídos de forma reversível que estavam
no bucket no momento da exclusão. Para restaurar objetos excluídos de forma reversível depois que o bucket excluído de forma reversível for restaurado, será necessário realizar uma operação de restauração de objeto.
As vinculações de tags podem não ser recuperadas quando você restaura um bucket excluído de forma reversível com tags. Para evitar a perda de dados, ao restaurar um bucket excluído temporariamente com
associações de tags, recomendamos verificar se as associações de tags do bucket foram
recuperadas. Se as vinculações de tags do bucket não foram recuperadas, vincule manualmente as tags não recuperadas ao bucket.
Permissões necessárias
Para receber as permissões necessárias para restaurar buckets excluídos de maneira reversível,
peça ao administrador para conceder a você o
papel do IAM de Administrador do Storage (roles/storage.admin)
no projeto do Cloud Storage.
Esse papel predefinido contém
as permissões necessárias para restaurar buckets excluídos de maneira reversível. Para conferir as permissões exatas
necessárias, expanda a seção Permissões necessárias:
Permissões necessárias
As seguintes permissões são necessárias para restaurar buckets excluídos de maneira reversível:
storage.buckets.list
storage.buckets.restore
Listar buckets excluídos de forma reversível
É possível realizar operações de lista para recuperar os metadados dos buckets excluídos temporariamente.
Use as instruções a seguir para listar todos os buckets excluídos de maneira reversível no seu projeto:
Linha de comando
Para listar todos os buckets excluídos de maneira reversível, use o comando
gcloud storage ls:
BUCKET_NAME: o nome do bucket excluído
de forma reversível que você quer restaurar.
GENERATION_NUMBER: o número de geração permanente e exclusivo do bucket excluído de maneira reversível que você quer restaurar.
Para saber o número de geração do seu bucket, consulte
Listar buckets excluídos de maneira reversível.
BUCKET_NAME é o nome do bucket
que você quer restaurar. Por exemplo, my-bucket.
GENERATION_NUMBER é o número de geração permanente e exclusivo do bucket excluído de maneira reversível que você quer restaurar. Para saber o número de geração do seu bucket, consulte
Listar buckets excluídos de maneira reversível.
O Cloud Storage restaura o bucket excluído de maneira reversível para um estado ativo. A restauração do bucket não restaura os objetos que estavam nele no momento da exclusão reversível. Para restaurar os objetos excluídos de maneira reversível que estavam no
bucket no momento da exclusão, consulte Restaurar um objeto excluído de maneira reversível.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 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)."]]