Reach the main text directly
HelpdeskDen

S3 lifecycle rules: 4 checks for skipped small files

By
HelpdeskDen Editorial Team
Posted
Sources checked
Length
13 min read

S3 lifecycle rules can skip small files because the default prevents objects smaller than 128 KB from transitioning to any storage class.

Key takeaways

  • Match backup prefixes to lifecycle rules and check for gaps.
  • Confirm each intended rule is enabled before relying on it.
  • Compare object sizes with the 128 KB transition floor.
  • Review current tags and versioning before relying on expiration.

If you keep office backups in Amazon S3, you probably set up lifecycle rules once and then stopped thinking about them. Maybe you wanted older backup archives moved to a cheaper storage class after they stopped changing. Maybe you wanted old copies deleted after a set time so the storage bill stays predictable. Check which objects each rule covers before relying on it.

Small files are where this goes wrong. Think of the little things in an office share: a signed PDF of a lease, a two-page spreadsheet of payroll exports, a config backup from the router, a scanned document. Each one is tiny, and each one can fall outside the rule you think covers it. Amazon S3 also has a default that treats small objects differently from large ones, so a rule that looks right on paper can leave a folder of small files exactly where it was.

This post gives you four checks to run before you trust your lifecycle rules. None of them takes long. Together they will show you whether your small backup files are moving the way you expect, or being quietly left behind.

I am writing for someone who runs IT alone, so the steps assume you are the only person touching the bucket. You can do them in the S3 console or from the command line. I point out the commands where they save you time, and the rest works either way.

Why small files get skipped

The main reason is a default. The AWS documentation on lifecycle examples says it plainly: "Amazon S3 applies a default behavior to your Lifecycle configuration that prevents objects smaller than 128 KB from being transitioned to any storage class." (Examples of S3 Lifecycle configurations)

Pay attention to the word "transitioned." In S3 terms, a transition is when a rule moves an object from one storage class to another. The 128 KB floor is about that move. It does not tell you what happens to small files under an expiration rule, which is a different action. Keep the two apart in your head, and check each one on its own.

The default has also changed over time, which is why older guides can mislead you. The same AWS page dates the current default to September 2024. For the earlier period, it says: "Previous default transition behavior — Before September 2024, the default behavior allowed objects smaller than 128 KB to be transitioned only to the S3 Glacier Flexible Retrieval and S3 Glacier Deep Archive storage classes." (Examples of S3 Lifecycle configurations)

If you followed a guide from before September 2024, check which default your configuration uses before relying on its advice about small files.

Check 1: confirm which prefix each rule covers

A lifecycle rule can limit itself to objects whose key names begin with a given prefix. The AWS example makes this concrete. It describes two rules, and says: "Rule 1 applies to objects with the key name prefix classA/." It then says: "Rule 2 applies to objects with key name prefix classB/." (Examples of S3 Lifecycle configurations)

Check object key names against the rule's prefix. Use the key name when matching an object to a rule. That means a rule with the prefix backups/ covers every object whose name starts with that exact text. A file stored under backups-misc/ does not match it, even if you think of it as backup data. A file under Backups/ with a capital letter does not match it either.

For a one-person shop, this is a common gap. A folder gets created for one scanner, then a second scanner gets a new folder, then the NAS gets renamed, and the rule still points at the old name. Each change looks harmless when you make it. Together they leave a few folders outside every rule.

Here is a simple way to find those gaps:

  1. Write down every lifecycle rule and its prefix. If a rule has no prefix, review its other filters.
  2. List the top-level prefixes in the bucket. In the console, the bucket view shows them. From the command line, aws s3 ls s3://your-bucket/ lists the top-level prefixes.
  3. For each prefix that holds backup data, find the rule that covers it. If none does, you have a gap.
  4. Look hard at the near-misses. Watch for capital letters, extra words, a missing or extra trailing slash, and a year folder that a rule was never updated to include.

Once you have the list, you can see the whole picture at once. Many gaps are obvious when they are written next to each other. A folder called scans/ sitting beside a rule for Scans/ is hard to miss on paper and easy to overlook in a console.

Check 2: confirm each rule is enabled

Rules have a status. The AWS example shows this directly. It describes a configuration in which "Rule 1 is enabled and Rule 2 is disabled." (Examples of S3 Lifecycle configurations) A disabled rule does not act on anything, even when its prefix and settings are exactly right.

This happens more often than you would think. You create a rule to test something, you disable it when the test is done, and then you forget that it was the rule covering one of your folders. Or you copy a configuration from another bucket, switch off a rule you did not understand, and move on. Check the status rather than assuming the rule is enabled.

In the S3 console, open the bucket and go to the Management tab. The lifecycle rules list shows each rule and its status. Turn on any rule that should be running, but do this after you finish the other checks, so you know what the rule will touch. If a rule is disabled on purpose, write the reason next to it in your notes. A future you will need that reason.

From the command line, aws s3api get-bucket-lifecycle-configuration --bucket your-bucket prints the full configuration, including a status value for each rule. Save that output to a file before you change anything. You will use it in the audit at the end of this post, and it is also your fallback if an edit goes wrong.

Check 3: compare the 128 KB floor with your real file sizes

This is the check that matters most for small files. Pull a list of object sizes for the prefixes that hold backups. The command aws s3 ls --recursive --human-readable s3://your-bucket/backups/ lists each object with its size, so you can scan for anything under 128 KB. Change the prefix to match your own folders.

Once you have the list, count the small files and write down their folders. Then ask a simple question about each group: do I expect this to move to a colder storage class? If your answer is "yes, all of my backup archives should move," then under the default, the small files in the same prefix are the ones that will stay where they are. That is the "skipped" in this post's title. The rule does not fail. Its transition action excludes those objects under the default.

It helps to keep the stakes in proportion. A handful of small files takes up very little space, so the goal is not to squeeze every cent out of them. The goal is to know which files your rules actually touch. If you believe a folder is being archived and it is not, you need to find that out before you need a restore.

The AWS page also points to a separate section on constraints. Its text says: "For more information about lifecycle constraints, see Constraints and considerations for transitions." (Examples of S3 Lifecycle configurations) Read that section once, while you are working on this check. It covers the transition rules in more detail than a short post can, and it is the authoritative source when your own setup does not behave the way this post describes.

Once you know how many small files you have, you have three reasonable choices for them.

The first is to leave them in the standard tier. For a small set of files, this is often the simplest answer. Nothing has to change, and you avoid adding a rule that looks like it does more than it does.

The second is to bundle small files into a single archive, such as a zip file, before you upload them. A combined archive can be larger than the 128 KB floor, so it may be able to transition where the individual files could not. This changes how you restore, though. You will need to unzip the archive to get one file back. Test that restore before you rely on the bundle for anything important.

The third is to give small files their own prefix with a rule you have reviewed and understand. This makes the intent visible. It does not get around the default, so write the rule with the 128 KB floor in mind and check the result after it has had time to run.

Whichever you choose, write the decision down. The next person to look at the bucket, which may be you in a year, will want to know whether the small files were left out on purpose.

Illustrative example: checking a small backup group

You confirm that its rule is enabled and that the prefix matches. Each file is still below the default transition floor, so matching the prefix alone does not make it eligible to move. You decide to leave these files in their current storage class and record that decision in your admin notes.

Check 4: check tags and versions before you trust an expiration rule

Expiration is the other half of lifecycle management. It is the rule that deletes old objects after a set time. Two details can surprise you.

The first detail is tags. If a rule filters on tags, the tags matter at the moment the rule runs. The AWS page on expiring objects says: "At execution time, Amazon S3 re-evaluates the object's current tags." (Expiring objects) That means the tags an object has today decide what happens, not the tags it had when you uploaded it.

Here is how that can bite you. Suppose you tag backup files with a label that marks how long to keep them. If you later change the label on some files, perhaps while cleaning up after a project, the rule will follow the new label on its next run. Files you meant to keep may become eligible for expiration. Files you meant to remove may stay around because someone changed their tag.

So look at how your rules use tags. If none of your rules filter on tags, this is not a concern for you. If one does, list the objects it matches and check that the tags on those objects are what you expect. Keep your tagging simple and consistent. Do not use tags as sticky notes that you rewrite every week.

The second detail is versioning. If your bucket keeps multiple versions of objects, review how your expiration rules handle them. The AWS expiring objects page points to its section on this topic: "For more information, see Retaining multiple versions of objects with S3 Versioning." (Expiring objects) Read that section before you assume that an expiration rule removes everything under a prefix. Check older versions as part of your review rather than relying only on the current copy.

To check versioning, open the bucket in the console and look at its Properties tab, where the versioning setting is shown. Whether versioning is on or off, record the answer in your notes next to your expiration rules. If versioning is on, make sure you know how your rules treat older versions, not just the current copy.

A quick lifecycle audit

Here is the whole process in one place. It is the sequence I would follow on a bucket I had not looked at in a while.

  1. Save the current lifecycle configuration to a file with aws s3api get-bucket-lifecycle-configuration. Keep the date in the file name.
  2. List the prefixes that hold backups, along with their sizes. Use aws s3 ls with the prefixes you care about.
  3. Match each backup prefix to a rule. Mark every prefix with no matching rule as a gap.
  4. Confirm the status of every rule. Note any disabled rule and why it is disabled.
  5. Find the small files under the 128 KB floor. Decide, for each group, whether to leave it, bundle it, or give it its own prefix.
  6. Check whether any rule filters on tags. If one does, confirm that the tags on the matched objects are the ones you expect.
  7. Check whether versioning is on. If it is, read the versioning section of the expiring objects page and confirm how your expiration rules treat old versions.
  8. Write the date and your results in your admin notes.

Repeat the audit whenever you add a new backup job, rename a folder, change backup software, or change how files are named. Those are the moments when prefixes and tags drift out of step with the rules. For a related review after backup jobs, use the backup verification checklist.

When you find a gap

Change one thing at a time. Save the current configuration before you edit it, so you can put it back if needed. If you can, apply the change to a test prefix first. Upload a few sample files of each size you care about, let them sit, and check the results. Give the rule time to run before you judge it. The results will not appear the moment you save the rule.

When you check the results, use the same method as the audit. Look at the objects, not the rule. The rule shows what you asked for. The object list shows what happened.

Also test a restore. This is the step that is easiest to skip, and it is the only one that tells you whether your backups are usable. Pick a small file and a large file from each prefix, restore them, and open them. If a bundled archive is part of your plan, restore the bundle and unzip it. A backup you have never restored is a guess, and a lifecycle rule that moved your small files somewhere you did not expect can turn that guess into a problem. Use the backup restore test to plan that check.

Keep the rules and the folders in sync

Lifecycle rules are a bet that your file layout will stay the same. Most of the time it does not. Folders get renamed, scanners get replaced, backup software changes how it names files, and a tag gets changed by someone who did not know it mattered. Each of these can leave a set of files outside the rule you wrote.

Run through them once now, while you have time. Then put a reminder on your calendar to repeat the audit on a regular schedule. The point is not to build a perfect configuration. The point is to make sure the small files you care about are where you think they are, and that you can get them back when you need them.

Today, save your lifecycle configuration and choose one backup prefix to check against its rule before changing anything.

Related guides: Apple office device update rules: 6 checks · 3-2-1 backup rule review: 5 checks to confirm today · Compliance deadline and data rules: 9 checks today.

Questions about lifecycle rules

Does the small-file transition floor explain expiration?

No, transitions and expiration are different actions. Review expiration separately, including tag filters and versioning.

Should I change every rule at once?

Change one thing at a time and check the results on a test prefix if you can. Keep the saved configuration so you can put it back if needed.

What should I check after bundling files?

Restore the bundle, unzip it, and open the files you need. Record the result alongside your lifecycle audit.

Sources