Soft delete

SetupUsage

This page describes the soft delete feature, which preserves objectsand buckets that get deleted or overwritten for a specified period of time.Soft delete helps protect your data from accidental ormalicious deletion by retaining deleted objects or buckets in a soft-deletedstate, during which the object or bucket cannot be permanently deleted.Soft delete is enabled by default on all buckets and has aretention duration of seven days unless you or your organization havechosen a different policy.

Note: Enabling soft delete on buckets containing primarilyshort-lived, temporary data can result in significantly increased storagecosts. To learn how to mitigate soft delete costs withoutcompromising data protection, seesoft delete cost optimization.

Overview

When you enable soft delete on a bucket, deleting the bucket or theobjects within the bucket results in the resource entering asoft-deleted state instead of being permanently deleted. Soft-deletedobjects and buckets behave in the following ways:

To enable soft delete on a bucket, you create asoft delete policy that specifies aretention durationcontrolling how long the bucket and objects within it are retained before theyget permanently deleted.

To learn how to set and manage a soft delete policy to enable or disablesoft delete on a bucket, seeUse soft delete.

Soft delete policies

By default, soft delete is enabled on all newly created buckets. Youcan edit a soft delete policy to enable or disablesoft delete for a bucket. A soft delete policy can be set, deleted,or edited during a bucket creation or update request.

Soft delete policies behave in the following ways:

  • Updating a bucket's soft delete policy only applies to objects that youdelete after the soft delete policy takes effect. Objects that youdeleted prior to the update are retained for the duration that was in effectwhen they were deleted.

    For example, say you enable a soft delete policy in your bucket with thedefault retention duration of seven days, and then you delete the objectcat.png. In this scenario,cat.png is retained as a soft-deleted objectfor the next seven days, and then it's permanently deleted. This occurs evenif you later change or remove the soft delete policy for your bucket.

  • If you add a new soft delete retention duration to an existingbucket, it won't apply to any of the objects or buckets that were deletedbefore the soft delete policy takes effect.

  • If you delete your project, you cannot use soft delete torestore the buckets or objects in it, even if they had soft deleteenabled. To ensure you don't lose your data in case of malicious oraccidental deletion, we recommend limiting access to project-level deletionbyplacing a lien on your projects or backing up business-criticaldata to buckets in a different project.

  • If a bucket is deleted, the objects within it are not permanentlydeleted but cannot be listed or restored unless the soft-deleted bucket isrestored. When you restore a soft-deleted bucket by using thegcloud CLI or JSON API, the bucket is restoredwithout live objects in it. You'll need to either perform an objectrestore operation or add new objects in it. You can restore a soft-deletedbucket and its objects at the same time by using the Google Cloud console.To learn more about using soft-deleted buckets, seeRestore a soft-deleted bucket.

  • When you enable or change a soft delete policy, the change can take up to30 seconds to fully propagate. During this time, the previous settingsstill apply. For example:

    • If you just enabled soft delete, objects deleted within the30 second window might still be permanently deleted.

    • If you changed the soft delete retention period, objects deletedwithin the 30 second window are retained based on the oldretention period.

Soft delete retention duration

Within a soft delete policy's retention duration, you can restore deletedobjects or buckets, but after the duration ends, Cloud Storagepermanently deletes the soft-deleted resource.

When you create a bucket, a soft delete policy is added to thebucket with a default retention duration of seven days. You canedit a policy's retention duration orset a new default retention duration. The maximum retention duration youcan set is 90 days and the minimum retention duration you can set is 7 days. Youcan also set the retention duration to0 to disable soft delete onthe bucket.

Restoration of soft-deleted objects

When you restore a soft-deleted object, Cloud Storage creates a copyof the soft-deleted object in the same bucket.

Restore behavior for soft-deleted objects can be described as the following:

  • When you restore a soft-deleted object, Cloud Storage creates a new, liveversion of the object in the same bucket. The soft-deleted version of theobject remains in the bucket until its retention duration expires.

    In some cases, if a live object already exists with the same name as thesoft-deleted object at the time of restoration, the restored object replacesthe live object, and the live object is then soft-deleted. In such ascenario, your bucket contains the following objects:

    • The replaced live object that is archived or in the soft-deleted state.

    • Two copies of the previously soft-deleted object, one live copy and onestill-soft-deleted copy.

  • Soft-deleted objects can be restored using multiple methods. You canrestore the soft-deleted objects synchronously, or you can create along-running operation to bulk restore objects that meet a certaincriteria.

Restoration of soft-deleted objects in buckets with hierarchical namespace enabled

Although rare, duplicate soft-deleted objects with identical names andgeneration values can occur inbuckets with hierarchical namespace enabled. Consider this scenario:

  1. ObjectfolderA/my-object.txt is soft-deleted.
  2. Its parent folder,folderA, is then deleted.
  3. A different object,folderB/my-object.txt, is moved to the original path byrenamingfolderB tofolderA. This object now becomesfolderA/my-object.txt.
  4. This newfolderA/my-object.txt object is also soft-deleted.

While each object version in Cloud Storage has a unique generationvalue, independently created objects like the originalfolderA/my-object.txtandfolderB/my-object.txt might coincidentally share the same generationvalue. Combined with the scenario, this can result in two soft-deleted objectswith the identical names (folderA/my-object.txt) and generation values.

To make sure you correctly restore, list, or get the right object, include therestoreToken parameter in your request.

When using soft delete in buckets with hierarchical namespace enabled,consider the following information:

  • If you try to restore, list, or get duplicate objects withoutusing therestoreToken parameter, you receive an error asking you touse therestoreToken parameter in your object restore or object listrequest.

  • If you use the wrong values for therestoreToken,name, orgenerationparameters as part of your object restore, list, or get request, youreceive an error indicating that the specified object does not exist.

Restoration of buckets

When you restore a soft-deleted bucket, it returns to a live state and theobjects that were in the bucket at the time of deletion also become recoverablewithin the soft delete retention duration.

Like soft-deleted objects,Cloud Storage permanently deletes a soft-deleted bucket at the end ofthe soft delete retention duration if the soft-deleted bucket isn'trestored during the retention duration.

Pricing

Soft-deleted objects incur storage charges until the soft-deleted objectsare permanently deleted after the retention duration is over. For moreinformation about costs associated with soft-deleted objects, seeCloud Storage pricing.

Soft delete cost optimization

To help lower storage costs on short-lived, temporary objects while maintainingdata protection, we recommend the following:

  • Rename objects: use theObjects: move API to rename a short-lived,temporary object rather than copying the object and deleting the original.

  • Separate temporary data: when possible, separate temporary data into aseparate bucket with soft delete disabled.

Interactions with other products and features

When soft delete is enabled, it behaves with other products andfeatures in the following ways:

  • Object Lifecycle Management:

    • Object Lifecycle Management rules don't affect soft-deleted objects. It isnot possible to use Object Lifecycle Management to change the storage classof soft-deleted objects or to permanently delete then.

    • Objects deleted by Object Lifecycle Management become soft-deleted. If youalso have Object Versioning enabled on your bucket, deleted live objectsbecome noncurrent and deleted noncurrent objects become soft-deleted.

  • Object Versioning: When you delete a noncurrent object, it becomessoft-deleted.

  • XML API multipart uploads: XML API multipart uploadparts are notprotected by soft delete.

  • Autoclass:

    • Autoclass management fees are not assessed for soft-deleted objects.

    • Autoclass does not change the storage class of soft-deleted objects.

    • When you restore a soft-deleted object, the resulting object is set tothe Standard storage class.

  • Bucket Lock andObject Retention Lock features: These features willprevent you from deleting objects until they fulfill their retention policies.Soft delete then provides an additional layer ofprotection by retaining deleted objects for a separate soft deleteretention duration.

  • Pub/Sub notifications: Restoring a soft-deleted version of anobject triggers anOBJECT_FINALIZE event.

  • Managed folders: Soft delete cannot restore theIAM policies onmanaged folders. If you soft deletean object and delete a managed folder that grants IAM policiesfor the object, you might have to recreate those IAM policiesbefore you have the necessary permissions to restore the soft-deleted object.

  • Tags: If you create a bucket without including asoft delete setting yourself, the Cloud Storage defaultis to create the bucket with a seven day soft delete retentionduration. You can change this default byusing a tag.The tag can change the default retentionduration for new buckets to be any value between 7 and 90 days, or it canchange the default to disable soft delete on new buckets.You can also use tags to disable soft delete by default.

  • Recommender: You can enable the Recommender APIto receive suggestions and insights on enabling or disablingsoft delete based on Cloud Billing costs and usage. To learn more,seesoft delete recommender.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.