Exclude Prefixes
You can exclude up to 10 prefixes on a bucket with versioning enabled.
This is especially useful for Spark or Hadoop workloads or any process that initially creates objects with temporary prefixes.
Prefixes
A prefix is a common leading string of characters under a bucket that a set of objects share.
Consider a bucket with the following contents
ALIAS/team-bucket/reports/2025/june.docx
ALIAS/team-bucket/reports/2025/may.docx
ALIAS/team-bucket/reports/2025/april.docx
ALIAS/team-bucket/reports/2025/march.docx
ALIAS/team-bucket/template/team-reports.dotx
ALIAS/team-bucket/graphics/team-photo.jpg
The string reports/2025/
is shared by the reports for March, April, May, and June, making reports/2025/
a prefix for those objects.
However, the template and the team-photo do not share the same beginning set of characters and are therefore not part of the prefix.
You can exclude the prefixes for template
and graphics
from versioning while allowing versioning to track changes to team reports in the reports/2025/
prefix.
Behavior
The list of --excluded-prefixes
match all objects containing the specified string in their prefix or name, similar to a regular expression of the form prefix*
.
To match objects by prefix only, use prefix/*
.
Procedure
Resume versioning a prefix
You can re-enable versioning of a prefix or all prefixes in a bucket at any time.
Objects created in a prefix before versioning is re-enabled will have a null
version ID after re-enabling versioning for the prefix.
Review a list of excluded prefixes
To see a list of excluded prefixes and other versioning options enabled for a bucket, use mc version info ALIAS/BUCKET
with the --json
option.
mc version info ALIAS/BUCKET --json
The output resembles the following, with the list of excluded prefixes in the ExcludedPrefixes
property:
$ mc version info local/my-bucket --json
{
"Op": "info",
"status": "success",
"url": "local/my-bucket",
"versioning": {
"status": "Enabled",
"MFADelete": "",
"ExcludedPrefixes": [
"prefix1, prefix2"
]
}
}