Create a Lifecycle Rule with the CLI
    • Dark
      Light

    Create a Lifecycle Rule with the CLI

    • Dark
      Light

    Article summary

    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.

    To use Lifecycle Rules with the Backblaze B2 Cloud Storage command-line interface (CLI), you need to run version 0.7.0 of the Backblaze B2 command-line tool.

    Use the following commands to create and manage Lifecycle Rules in the CLI.

    b2 bucket create [–-bucket-info <json>] [–-lifecycle-rules <json>] <bucketName> [allPublic | allPrivate]
    b2 bucket update [–-bucket-info <json>] [–-lifecycle-rules <json>] <bucketName> [allPublic | allPrivate]
    b2 bucket get <bucketName>

    The B2 bucket get command returns all of the variables for the named bucket.

    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.


    Was this article helpful?