# Tigris Lifecycle Management

Automate object expiration, storage tier transitions, and cleanup with lifecycle rules. Set policies that automatically delete temporary files, archive old data, and control storage costs.

## When to use[​](#when-to-use "Direct link to When to use")

Use when setting up automatic object expiration, storage tier transitions, TTL-based deletion, or cleanup rules for Tigris buckets

## Install the skill[​](#install-the-skill "Direct link to Install the skill")

```
npx skills add tigrisdata/skills --skill tigris-lifecycle-management
```

This page is generated from [`skills/tigris-lifecycle-management/SKILL.md`](https://github.com/tigrisdata/skills/blob/main/skills/tigris-lifecycle-management/SKILL.md) in the [tigrisdata/skills](https://github.com/tigrisdata/skills) repository.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

**Before doing anything else**, install the Tigris CLI if it's not already available:

```
tigris help || npm install -g @tigrisdata/cli
```

If you need to install it, tell the user: "I'm installing the Tigris CLI (`@tigrisdata/cli`) so we can work with Tigris object storage."

## Quick Reference[​](#quick-reference "Direct link to Quick Reference")

| Operation    | Command                                                         |
| ------------ | --------------------------------------------------------------- |
| Set rules    | `tigris buckets lifecycle set <bucket> --config lifecycle.json` |
| View rules   | `tigris buckets lifecycle get <bucket>`                         |
| Remove rules | `tigris buckets lifecycle delete <bucket>`                      |

***

## Setting Lifecycle Rules[​](#setting-lifecycle-rules "Direct link to Setting Lifecycle Rules")

```
tigris buckets lifecycle set my-app-uploads --config lifecycle.json
```

### Rule Format[​](#rule-format "Direct link to Rule Format")

```
{

  "Rules": [

    {

      "ID": "rule-name",

      "Filter": { "Prefix": "path/prefix/" },

      "Status": "Enabled",

      "Expiration": { "Days": 30 },

      "Transitions": [

        { "Days": 7, "StorageClass": "STANDARD_IA" },

        { "Days": 90, "StorageClass": "GLACIER" }

      ]

    }

  ]

}
```

| Field             | Purpose                                    |
| ----------------- | ------------------------------------------ |
| `ID`              | Human-readable rule name                   |
| `Filter.Prefix`   | Only apply to objects matching this prefix |
| `Status`          | `"Enabled"` or `"Disabled"`                |
| `Expiration.Days` | Delete objects after N days                |
| `Transitions`     | Move objects between storage tiers         |

***

## Common Patterns[​](#common-patterns "Direct link to Common Patterns")

### Temporary Upload Cleanup[​](#temporary-upload-cleanup "Direct link to Temporary Upload Cleanup")

Delete files in `tmp/` after 24 hours:

```
{

  "Rules": [

    {

      "ID": "cleanup-temp-uploads",

      "Filter": { "Prefix": "tmp/" },

      "Status": "Enabled",

      "Expiration": { "Days": 1 }

    }

  ]

}
```

### Unverified Upload Expiration[​](#unverified-upload-expiration "Direct link to Unverified Upload Expiration")

Delete unprocessed uploads after 7 days:

```
{

  "Rules": [

    {

      "ID": "expire-unverified-uploads",

      "Filter": { "Prefix": "uploads/pending/" },

      "Status": "Enabled",

      "Expiration": { "Days": 7 }

    }

  ]

}
```

### Session Data Cleanup[​](#session-data-cleanup "Direct link to Session Data Cleanup")

Auto-delete session files after 1 day:

```
{

  "Rules": [

    {

      "ID": "cleanup-sessions",

      "Filter": { "Prefix": "sessions/" },

      "Status": "Enabled",

      "Expiration": { "Days": 1 }

    }

  ]

}
```

### Log Archival[​](#log-archival "Direct link to Log Archival")

Move logs to cheaper storage, then delete after 1 year:

```
{

  "Rules": [

    {

      "ID": "archive-logs",

      "Filter": { "Prefix": "logs/" },

      "Status": "Enabled",

      "Transitions": [

        { "Days": 30, "StorageClass": "STANDARD_IA" },

        { "Days": 90, "StorageClass": "GLACIER" }

      ],

      "Expiration": { "Days": 365 }

    }

  ]

}
```

### Backup Retention[​](#backup-retention "Direct link to Backup Retention")

Keep backups for 30 days:

```
{

  "Rules": [

    {

      "ID": "expire-old-backups",

      "Filter": { "Prefix": "backups/" },

      "Status": "Enabled",

      "Expiration": { "Days": 30 }

    }

  ]

}
```

### Old Asset Versions[​](#old-asset-versions "Direct link to Old Asset Versions")

Clean up old build artifacts:

```
{

  "Rules": [

    {

      "ID": "cleanup-old-builds",

      "Filter": { "Prefix": "builds/" },

      "Status": "Enabled",

      "Expiration": { "Days": 14 }

    }

  ]

}
```

***

## Storage Tiers[​](#storage-tiers "Direct link to Storage Tiers")

| Tier          | Cost    | Access                  | Use For                             |
| ------------- | ------- | ----------------------- | ----------------------------------- |
| `STANDARD`    | Highest | Instant                 | Frequently accessed files           |
| `STANDARD_IA` | Lower   | Instant, retrieval fee  | Infrequent access (>30 days old)    |
| `GLACIER`     | Lowest  | Minutes-hours retrieval | Archives, compliance (>90 days old) |

### When to Transition[​](#when-to-transition "Direct link to When to Transition")

| Scenario                        | Transition At                 | Save                |
| ------------------------------- | ----------------------------- | ------------------- |
| User uploads rarely re-accessed | 30 days → IA                  | \~40% storage cost  |
| Compliance archives             | 90 days → Glacier             | \~80% storage cost  |
| Build artifacts                 | 7 days → IA, 30 days → delete | \~90% with deletion |

***

## Multiple Rules Example[​](#multiple-rules-example "Direct link to Multiple Rules Example")

Combine rules for a complete lifecycle policy:

```
{

  "Rules": [

    {

      "ID": "cleanup-temp",

      "Filter": { "Prefix": "tmp/" },

      "Status": "Enabled",

      "Expiration": { "Days": 1 }

    },

    {

      "ID": "archive-uploads",

      "Filter": { "Prefix": "uploads/" },

      "Status": "Enabled",

      "Transitions": [{ "Days": 90, "StorageClass": "STANDARD_IA" }]

    },

    {

      "ID": "expire-backups",

      "Filter": { "Prefix": "backups/" },

      "Status": "Enabled",

      "Expiration": { "Days": 30 }

    },

    {

      "ID": "archive-logs",

      "Filter": { "Prefix": "logs/" },

      "Status": "Enabled",

      "Transitions": [

        { "Days": 30, "StorageClass": "STANDARD_IA" },

        { "Days": 90, "StorageClass": "GLACIER" }

      ],

      "Expiration": { "Days": 365 }

    }

  ]

}
```

***

## Application-Level TTL[​](#application-level-ttl "Direct link to Application-Level TTL")

When lifecycle rules aren't granular enough (e.g., expiration based on metadata, not age), implement TTL in your application:

```
import { put, list, remove, head } from "@tigrisdata/storage";



// Store with expiration metadata

await put("tokens/abc123.json", data, {

  contentType: "application/json",

  // Store expiry as part of the key or track in your database

});



// Cleanup job: delete expired objects

async function cleanupExpired(prefix: string, maxAgeMs: number) {

  const result = await list({ prefix });

  const now = Date.now();



  for (const item of result.data?.items ?? []) {

    const age = now - new Date(item.modified).getTime();

    if (age > maxAgeMs) {

      await remove(item.path);

    }

  }

}



// Run daily

cleanupExpired("tokens/", 24 * 60 * 60 * 1000); // 24 hours
```

***

## Interaction with Snapshots[​](#interaction-with-snapshots "Direct link to Interaction with Snapshots")

* Lifecycle rules apply to the source bucket, not snapshot copies
* Objects deleted by lifecycle rules can be recovered from snapshots (if taken before deletion)
* Consider snapshot frequency when setting expiration policies

***

## Critical Rules[​](#critical-rules "Direct link to Critical Rules")

**Always:** Use lifecycle rules for predictable cleanup patterns | Set expiration on temporary/transient data | Use storage tier transitions for cost savings | Test rules on a non-production bucket first

**Never:** Rely solely on lifecycle for critical data deletion (add application-level checks) | Set short expiration on buckets with important data without backups | Forget that deleted objects are gone permanently (unless you have snapshots)

***

## Related Skills[​](#related-skills "Direct link to Related Skills")

* **tigris-backup-export** — Backup retention policies
* **tigris-egress-optimizer** — Tier transitions for cost savings
* **tigris-snapshots-forking** — Point-in-time recovery before deletion

## Official Documentation[​](#official-documentation "Direct link to Official Documentation")

* Tigris: <https://www.tigrisdata.com/docs/>
