Soft delete (original) (raw)

Setup Usage

This page describes the soft delete feature, which preserves objects and buckets that get deleted or overwritten for a specified period of time. Soft delete helps protect your data from accidental or malicious deletion by retaining deleted objects or buckets in a soft-deleted state, 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 have chosen a different policy.

Overview

When you enable soft delete 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. Soft-deleted objects and buckets behave in the following ways:

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

To learn how to set and manage a soft delete policy to enable or disable soft delete on a bucket, see Use soft delete.

Soft delete policies

By default, soft delete is enabled on all newly created buckets. You can edit a soft delete policy to enable or disable soft 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:

Soft delete retention duration

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

When you create a bucket, a soft delete policy is added to the bucket 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 you can set is 90 days and the minimum retention duration you can set is 7 days. You can also set the retention duration to 0 to disable soft delete on the bucket.

Restoration of soft-deleted objects

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

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

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

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

  1. Object folderA/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 by renaming folderB to folderA. This object now becomesfolderA/my-object.txt.
  4. This new folderA/my-object.txt object is also soft-deleted.

While each object version in Cloud Storage has a unique generation value, independently created objects like the original folderA/my-object.txtand folderB/my-object.txt might coincidentally share the same generation value. Combined with the scenario, this can result in two soft-deleted objects with 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:

Restoration of buckets

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

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

Pricing

Soft-deleted objects incur storage charges until the soft-deleted objects are permanently deleted after the retention duration is over. For more information 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 maintaining data protection, we recommend the following:

Interactions with other products and features

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

What's next