Managing bucket object lifecycles
Object Storage allows you to manage object lifecycles in a bucket.
Changes are applied to lifecycles at 00:00 UTC, every 24 hours.
-
In the management console
, go to the bucket you want to configure object lifecycles for. -
Select Lifecycle.
-
Click Configure.
-
On the page that opens, you can add, remove, and edit configuration rules.
To create a rule:
- Enable Status. With this option, you can enable or disable a rule without deleting it from a configuration.
- Fill out the fields below:
- Description: Provide the rule description as you see fit.
- Prefix: Characters taken from the beginning of the object key of the required length. The prefix is used to match objects to a rule. If a rule must apply to all objects, select All objects.
- Select an object type and the action to apply to objects when the rule is triggered:
Expiration
: Remove all objects from bucket.NoncurrentVersionExpiration
: Remove non-current object versions from bucket.AbortIncompleteMultipartUpload
: Remove of all parts of failed multipart uploads from bucket.
- Select the rule trigger. Depending on type, you can select:
- Number of days: Rule gets triggered after a specified number of days.
- Exact date: On a specified date.
- Deletion marker without noncurrent versions: After an object has only one current version. Valid only for the
Expiration
type.
- Select a rule trigger time:
- Trigger time: Number of days after an object is uploaded. The rule gets triggered after this number of days. The minimum value is 1.
- Trigger date: Date when a rule gets triggered.
- Click Save.
You can add multiple rules at once. To add a new rule, click Add rule and repeat the above steps.
Note
In the management console, you can't use a single rule to set the criteria for deleting objects. Use a separate rule for each type of criteria.
If you don't have the Nebius AI command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
Define the object lifecycle configuration in JSON format, e.g.:
{ "lifecycleRules": [ { "id": "DeleteOldBackups", "enabled": true, "filter": { "prefix": "test/" }, "expiration": { "days": 180 } } ] }
Possible configuration parameters:
id
: Unique rule ID. Length: 255 characters or less. Optional parameter.enabled
: Rule status. Required parameter.filter
: Object filter. Optional parameter. It may contain:prefix
: Object key prefix that identifies one or more objects the rule applies to. Optional parameter.
expiration
: Parameter of a rule for deleting any objects. Optional parameter. It may contain:date
: Date after which you want the rule to take effect. Optional parameter.days
: Number of days after creating an object when the rule takes effect. The minimum value is 1. Optional parameter.
noncurrent_version_expiration
: Parameter of a rule for deleting non-current object versions. Optional parameter. It may contain:days
: Number of days before expiration. The minimum value is 1. Required parameter.
abort_incomplete_multipart_upload_days
: Parameter of a rule for removing all parts of multipart uploads that were not completed within the specified number of days. Optional parameter.
Make sure to specify at least one of the following parameters:
transition
,expiration
,noncurrent_version_transition
,noncurrent_version_expiration
, orabort_incomplete_multipart_upload_days
.Once completed, save the configuration to a file, such as
lifecycles.json
. -
View a description of the CLI command to update a bucket:
ncp storage bucket update --help
-
Get a list of buckets in the default folder:
ncp storage bucket list
Result:
+------------------+----------------------+-------------+-----------------------+---------------------+ | NAME | FOLDER ID | MAX SIZE | DEFAULT STORAGE CLASS | CREATED AT | +------------------+----------------------+-------------+-----------------------+---------------------+ | first-bucket | b1gmit33ngp6******** | 53687091200 | STANDARD | 2022-12-16 13:58:18 | +------------------+----------------------+-------------+-----------------------+---------------------+
-
Using the
NAME
column, save the name of the bucket to set up the lifecycles in. -
Run the following command:
ncp storage bucket update \ --name <bucket_name> \ --lifecycle-rules-from-file <configuration_file_path>
Where:
--name
: Name of the bucket to set up the lifecycles in.--lifecycle-rules-from-file
: Path to the lifecycle configuration file.
The configuration specified in the command overrides the current bucket lifecycle settings. You can retrieve the current settings using the
ncp storage bucket get <bucket_name> --full
command.
To remove the lifecycle configuration, run this command:
ncp storage bucket update \
--name <bucket_name> \
--remove-lifecycle-rules
To upload a configuration via the AWS CLI:
-
Define the object lifecycle configuration in JSON format, e.g.:
{ "Rules": [ { "ID": "DeleteOldBackups", "Filter": { "Prefix": "backup/" }, "Status": "Enabled", "Expiration": { "Days": 180 } } ] }
Possible configuration parameters:
-
ID
: Unique rule ID. Length: 255 characters or less. Optional parameter. -
Filter
: Object filter. Optional parameter. It may only contain one element of each type:Prefix
: Key prefix. The rule applies to objects with the specified key prefix. Optional parameter.ObjectSizeGreaterThan
: Minimum object size in bytes. The rule applies to objects whose size is greater than or equal to the set one. Optional parameter.ObjectSizeLessThan
: Maximum object size in bytes. The rule applies to objects whose size is less than or equal to the set one. Optional parameter.
If no object filter is set, the rule applies to all objects in the bucket.
-
Status
: Rule status. Required parameter. Values:Enabled
: Rule enabled.Disabled
: Rule disabled.
-
Expiration
: Parameter of a rule for deleting any objects. Optional parameter. It may contain:Date
: Date after which the object will be deleted. Format: ISO 8601, e.g.,YYYY-MM-DD
. Time: always 00:00 UTC. Optional parameter.Days
: Number of days since the creation of the object, after which the object will be deleted. The minimum value is1
. Optional parameter.
-
NoncurrentVersionExpiration
: Parameter of a rule for deleting non-current object versions. Optional parameter.The rule has the required
NoncurrentDays
parameter that indicates the number of days before deleting non-current object versions. The minimum value is1
. -
AbortIncompleteMultipartUpload
: Parameter of a rule for removing all parts of multipart uploads that were not completed within the specified number of days. Optional parameter.The rule has the required
DaysAfterInitiation
parameter that indicates the number of days since the upload start. The minimum value is1
.
Make sure to specify at least one of the following parameters:
Expiration
,NoncurrentVersionExpiration
, orAbortIncompleteMultipartUpload
.Once completed, save the configuration to a file, such as
lifecycles.json
. -
-
Upload the configuration to a bucket, like
backup-bucket
:aws s3api put-bucket-lifecycle-configuration \ --bucket backup-bucket \ --endpoint-url=https://storage.ai.nebius.cloud \ --lifecycle-configuration file://lifecycles.json