- Print
- DarkLight
Create a Lifecycle Rule with the Native API
- Print
- DarkLight
Lifecycle Rules enable the Backblaze B2 Cloud Storage service to automatically hide and delete older versions of your files that are stored in Backblaze B2. Each Backblaze B2 bucket can have its own Lifecycle Rules, and you can apply Lifecycle Rules to some or all of the files in your bucket.
The following API calls are related to Lifecycle Rules:
b2_create_bucketThis operation creates a new bucket.b2_update_bucketThis operation changes the settings on a bucket.b2_list_bucketsThis operation lists all of the buckets in your account.
When you create a new bucket, you can specify the Lifecycle Rules. Later, you can update the rules on a bucket.
Each API call has an optional parameter called lifecycleRules that requires three variables in the following JSON format:
{
“daysFromHidingToDeleting”: 30,
“daysFromUploadingToHiding”: null,
“fileNamePrefix”: “backup/”
}In addition, the b2_delete_bucket operation returns the list of lifecycleRules for the bucket that you want to delete.
Managing Versioned Objects
While versioning provides valuable protection against accidental deletions and overwrites, uploading millions of versions of the same object into a bucket may significantly degrade performance of object deletion and listing operations, increase the rate of HTTP 503 (Service Unavailable) responses, and will eventually result in your account being blocked from further uploads.
To avoid this, configure lifecycle rules to automatically expire old versions after a specified number of days or limit the number of retained versions per object. If you suspect your account has been affected, contact Backblaze support for assistance.