What's new
Object Versioning is a per-bucket setting for Supabase Storage. Any project can turn it on. With versioning on:
- An overwrite keeps the previous version of the file as a noncurrent version.
- A delete adds a delete marker and keeps the file's versions. The path returns
not_found, as before, and you can bring the file back. - Every version has a
versionId. List, download, restore, or permanently delete a version from the Dashboard,supabase-js2.116.0 or later, or the Storage API.
Lifecycle Policies are bucket rules that expire noncurrent versions after a set number of days. A rule can also keep a set number of the newest noncurrent versions. In that case, a version expires only when it's past the age limit and outside that set.
You can turn on versioning for a bucket that already has files. Turning it on doesn't change or delete them, and from then on, overwriting or deleting a file keeps the old one as a version. One exception: if you later suspend versioning, writing to a file that existed before versioning was on permanently replaces that original. Versioning also only protects changes made after you turn it on, so overwrites and deletes from before then can't be recovered. Nothing changes in how you upload, overwrite, or delete files, and buckets with versioning off behave exactly as they do today.
On self-hosted Supabase, versioning is off by default. Set STORAGE_VERSIONING_ENABLED=true on the Storage server to turn it on.
Kept versions count toward your Storage usage. See pricing for included storage and overage rates.
How to use it
Turn on versioning for a bucket:
_10await supabase.storage.updateBucket('avatars', {_10 public: false,_10 versioningStatus: 'ENABLED',_10})
List a file's versions, then restore one by moving it onto its own path:
_11const { data, error } = await supabase.storage.from('avatars').list('sidney/profile.png', {_11 exactMatch: true,_11 noncurrentVersions: 'include',_11 deleteMarkers: 'include',_11})_11_11await supabase.storage_11 .from('avatars')_11 .move('sidney/profile.png', 'sidney/profile.png', {_11 sourceVersionId: 'eaa8bdb5-2e00-4767-b5a9-d2502efe2196',_11 })
Undo a delete by deleting the delete marker that's the current version. The version underneath becomes current again:
_10await supabase.storage_10 .from('avatars')_10 .remove([{ path: 'sidney/profile.png', versionId: 'DELETE_MARKER_VERSION_ID' }])
Expire a noncurrent version only when it's older than 30 days and isn't one of the five newest noncurrent versions:
_10await supabase.storage.updateBucketLifecycle('avatars', {_10 rules: [_10 {_10 status: 'Enabled',_10 filter: {},_10 noncurrentVersionExpiration: { noncurrentDays: 30, newerNoncurrentVersions: 5 },_10 },_10 ],_10})
Known limitations in Public Alpha
- The S3-compatible endpoint works on versioned buckets, but it can't target a specific version yet. Uploads, overwrites, copies, and deletes over S3 follow the bucket's versioning status, the same as the Storage API: an overwrite keeps the previous version, and a delete adds a delete marker. A GetObject, HeadObject, GetObjectAttributes, DeleteObject, DeleteObjects, CopyObject, or UploadPartCopy request that names a version ID fails with a
NotSupportederror instead of acting on the current version. ListObjectVersions isn't available over S3 yet and returnsNotImplemented. You can still read and set a bucket's versioning status and lifecycle rules over S3. Use the Dashboard,supabase-js, or the Storage API to list, read, or restore versions. - Lifecycle rules apply to the whole bucket and only expire noncurrent versions. Prefix and tag filters, current-version expiration, and incomplete multipart upload cleanup aren't supported yet.
We're working on version operations over S3 and more lifecycle rule types.
Why we built this
Without versioning, file deletions and overwrites are final. If your app can't afford to lose a file to a scripting error or a rogue agent, Object Versioning gives you a way back. Lifecycle Policies help you automatically manage your prior versions so they don't grow unbounded and you don't have to delete them yourself.
What we'd like to know from you
Object Versioning and Lifecycle Policies are in public alpha, so your feedback shapes what we build next. Share it in the Object Versioning discussion on GitHub. We'd like to know:
- What you use versioning for.
- Which S3 version operations you need first, if you use the S3-compatible endpoint.
- Which lifecycle rules you're missing, such as prefix filters or current-version expiration.
- Any bugs or surprises, good or bad.
That discussion replaces the earlier requests for Storage versioning in #40482 and #8106.