Soft delete overview

Setup Usage

Soft delete helps protect your Cloud Storage data in case an object or bucket is accidentally or maliciously deleted. The soft delete feature preserves objects and buckets that get deleted or overwritten by retaining them in a soft-deleted state for a specified period of time. During this time, the object or bucket can't be permanently deleted and can be restored.

Soft delete is enabled by default for all buckets that support it, with a default retention duration of 7 days. You can set a different default retention duration by using tags.

This page describes how soft delete works.

Soft delete policies

When soft delete is enabled on a bucket, deleting the bucket or the objects within the bucket results in the resource entering a soft-deleted state instead of being permanently deleted. To enable soft delete on a bucket, you set a soft delete policy that defines how long soft-deleted resources are retained.

Soft delete policies work in the following ways:

  • The soft delete policy includes a retention duration that defines how long soft-deleted resources are retained before being permanently deleted. The default retention duration is 7 days and you can customize the retention duration to anywhere between 7 to 90 days. To disable soft delete, you set the retention duration to 0.

  • A default soft delete policy is automatically set on all newly created buckets, except for buckets that use products or capabilities that are incompatible with soft delete (such as zonal buckets that use Rapid Bucket).

  • You can set, edit, or disable a soft delete policy when you create or update a bucket.

    When you edit a soft delete policy, the changes you make only apply to resources that are deleted after the new policy takes effect. Resources that were deleted prior to the new policy taking effect are retained for the original retention duration that was in effect when the resource got deleted. In other words, existing soft-deleted resources continue to adhere to the retention period that was active at their time of deletion.

    For example, say you set a soft delete policy on a bucket that has a retention duration of seven days. You delete the object object-A.png, which becomes soft deleted. Next, you change the policy's retention duration to 10 days and then you delete the object object-B.png, which also becomes soft deleted. object-A.png will be retained for seven days in the soft-deleted state, while object-B.png will be retained for 10 days.

    Changes to the retention period of a soft delete policy take up to 30 seconds to propagate.

To learn how to set and manage soft delete policies on buckets, see Set and manage soft delete policies.

Properties of soft-deleted resources

When a bucket or object is deleted under an active soft delete policy, the resource transitions to a soft-deleted state. You can restore soft-deleted resources during their retention duration.

Soft-deleted resources have the following characteristics:

  • Soft-deleted objects and buckets cannot be read, modified, or overwritten. The only supported operations are listing them or restoring them.

  • Soft-deleted resources are hidden from list operations by default. To view soft-deleted resources, you must explicitly specify a flag or filter to view the resources.

  • You cannot modify a soft-deleted bucket or list its contents until the bucket itself is restored. The method you use to restore a soft-deleted bucket affects whether the objects in the bucket are also restored:

    • You can restore a soft-deleted bucket and its objects at the same time by using the Google Cloud console.

    • Restoring a bucket using the Google Cloud CLI or the JSON API restores only the empty bucket. You must then restore the objects in a separate operation to recover its contents.

  • If a bucket name is taken by a new live bucket, you can't restore the soft-deleted bucket until the conflicting live bucket is removed.

  • If your project is deleted, any bucket that has soft delete enabled is retained for the soft delete retention duration or the Google Cloud project recovery window, whichever time period is shorter. After this time period, the bucket is permanently deleted.

    If you restore a deleted project, buckets that were live when the project was deleted are restored as live buckets. Buckets that were soft-deleted when the project was deleted remain soft-deleted until their retention duration ends.

    Buckets that don't have soft delete enabled might be deleted immediately when a project is deleted, and might not be restorable.

  • Some Cloud Storage capabilities are compatible with soft delete policies but don't affect soft-deleted objects. Examples of such capabilities are Autoclass, Object Lifecycle Management, Bucket Lock, and Object Retention Lock.

For instructions on restoring soft-deleted objects or buckets, see Restore soft-deleted objects or Restore soft-deleted buckets.

Object restores

When you restore a soft-deleted object, Cloud Storage creates a new, live copy of that object within the same bucket. The original, soft-deleted version remains in the background until its retention period officially expires. The following list describes core restore behaviors:

  • When you restore an object, Cloud Storage generates a new version of the object. For more information about object versions, see Object immutability.

  • If a live object with the same name as a soft-deleted object already exists when you restore the soft-deleted object, the restored object will overwrite the existing live version. The overwritten object that was formerly live is then automatically soft-deleted.

    In this specific scenario, your bucket will contain two copies of the restored object (one new live copy and the old soft-deleted copy) alongside the newly soft-deleted version of the object that was overwritten.