A tool for managing S3 bucket versions and tombstones. It can restore a bucket to a specific point in time and clean up stale delete markers.
We welcome contributions! This quick guide shows how to build and run the integration-style tests locally.
- Prerequisites: Go 1.25+ and access to an S3-compatible endpoint (use the MinIO stack below for local dev).
- Using Makefile (recommended):
- Build:
make build(outputsbin/s3ctl). You can overrideGOOS/GOARCH, e.g.make build GOOS=linux GOARCH=amd64. - Run from source:
make run(equivalent togo run .). - Install to GOPATH/bin:
make install. - Clean artifacts:
make clean.
- Build:
- Plain Go:
go build -o bin/s3ctl .
Helpers under test/main.go exercise restore and tombstone-cleanup flows.
- Start a local S3-compatible service (optional): see "Local MinIO with Docker Compose". Export env vars for the endpoint:
S3_ENDPOINT,S3_ACCESS_KEY,S3_SECRET_KEY,S3_USE_SSL. - Prepare test data and capture a restore timestamp:
go run test/main.go setup(note the printed bucket andRESTORE_TIMESTAMP). - Build, then run commands against the test bucket:
- Restore:
export S3_BUCKET="<bucket>" RESTORE_TIMESTAMP="<timestamp>" && bin/s3ctl restore - Cleanup tombstones:
bin/s3ctl cleanup-tombstones
- Restore:
- Optional verifications:
go run test/main.go verify-restoreandgo run test/main.go verify-tombstone.
Please update this README if you change the flow.
This tool provides two main functions:
- Restore a bucket to a specific point in time by deleting object versions created after that timestamp.
- Remove stale delete markers (tombstones) that have no live versions.
- An S3-compatible storage system (e.g., MinIO, AWS S3)
- Properly configured environment variables (see below)
| Variable | Description |
|---|---|
S3_ENDPOINT |
S3 endpoint (e.g., localhost:9000) |
S3_ACCESS_KEY |
S3 access key |
S3_SECRET_KEY |
S3 secret key |
S3_BUCKET |
Target bucket name |
S3_USE_SSL |
Use SSL (true/false, default: false) |
restore— Restore a bucket to a specific point in time.- Options:
-dry-run(default:true). Example to actually apply changes:-dry-run=false.
- Options:
cleanup-tombstones— Delete stale delete markers (no live versions).- Options:
-dry-run(default:true).
- Options:
- Restore to a timestamp:
export S3_BUCKET="your-bucket" RESTORE_TIMESTAMP="2023-01-01T00:00:00Z" bin/s3ctl restore -dry-run=false
- Cleanup tombstones (preview only):
bin/s3ctl cleanup-tombstones
A minimal CI can:
- Run
go run test/main.go setupto create a versioned test bucket and produce aRESTORE_TIMESTAMP. - Execute
bin/s3ctl restore -dry-run=falsewith the printed timestamp, thengo run test/main.go verify-restore. - Execute
bin/s3ctl cleanup-tombstonesand thengo run test/main.go verify-tombstone.
A basic MinIO server is included for local testing.
- Copy the environment template and adjust credentials if desired:
cp .env.example .env
- Start MinIO:
docker compose up -d
- Access endpoints:
- MinIO Console: http://localhost:9001 (login with MINIO_ROOT_USER/MINIO_ROOT_PASSWORD)
- S3 API endpoint: http://localhost:9000
Export variables so the tools/tests can talk to MinIO:
export S3_ENDPOINT=localhost:9000
export S3_ACCESS_KEY=${MINIO_ROOT_USER:-minioadmin}
export S3_SECRET_KEY=${MINIO_ROOT_PASSWORD:-minioadmin123}
export S3_USE_SSL=falseThen follow the steps in the Usage section (e.g., go run test/main.go setup).
To stop/remove the stack:
docker compose down