CLI tool to clean up unfinished Backblaze B2 large uploads
Project description
b2-cleanup
🧹 A Python CLI tool to clean up unfinished large file uploads in a Backblaze B2 bucket.
Built using b2sdk, click, and uv for performance and reproducibility.
🔧 Features
- Lists all unfinished large file uploads in a given B2 bucket
- Optionally cancels them (dry-run support included)
- Uses the official
b2sdkfor native Backblaze API access - Supports authentication via env vars, CLI override, or the
b2CLI - Clean CLI with logging support
- Class-based and easily extensible
🚀 Installation
1. Clone and create an isolated environment
git clone https://github.com/<your-username>/b2-cleanup.git
cd b2-cleanup
uv venv
source .venv/bin/activate
uv pip install -e .
Requires uv and Python 3.8+
🧪 Usage
b2-cleanup BUCKET_NAME [OPTIONS]
Example (dry run):
b2-cleanup my-bucket --dry-run
Example (delete for real, with logging):
b2-cleanup my-bucket --log-file cleanup_$(date +%F).log
Example (override credentials):
b2-cleanup my-bucket --key-id my-key-id --key my-app-key
🔐 Authentication
This tool supports three ways to authenticate with B2, in priority order:
-
Explicit CLI arguments:
b2-cleanup my-bucket --key-id abc123 --key supersecretkey
-
Environment variables:
export B2_APPLICATION_KEY_ID=abc123 export B2_APPLICATION_KEY=supersecretkey
-
The
b2CLI (must be previously authorized):b2 account authorize # Then the tool will read credentials via: b2 account info
📁 Project Structure
b2-cleanup/
├── cleanup_unfinished_b2_uploads.py # Core CLI logic (class-based)
├── pyproject.toml # Project metadata + dependencies
├── .gitignore
└── README.md
📦 Packaging Notes
- The CLI entry point is
b2-cleanupviapyproject.toml - Install in editable mode (
uv pip install -e .) for fast development - Dependencies are managed via
uv
🛠️ Roadmap
- Filter uploads by file age
- Support multiple buckets
- Output metrics (count, size, cost saved)
- Optional integration with S3-compatible B2 APIs
📝 License
MIT License © 2025 Jeroen Verhoeven
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file b2_cleanup-0.1.3.tar.gz.
File metadata
- Download URL: b2_cleanup-0.1.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fab36e56497f006d87ef1ede7eb134c50d1d601189a5dfb692db3e262453b204
|
|
| MD5 |
808251644d4991e97693c2403ba67965
|
|
| BLAKE2b-256 |
75c8c661d77f3703047e897cb1e2be864e9234be42d454d7db06d6a8b14712af
|
File details
Details for the file b2_cleanup-0.1.3-py3-none-any.whl.
File metadata
- Download URL: b2_cleanup-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e9b2d6872ae719d6297c5a63130bfe4e579dda6cef21a355bd1db9be67306d0
|
|
| MD5 |
2ef48828239b80773c79f45d3045cdee
|
|
| BLAKE2b-256 |
39633fcbfcb1b3e63a052aa2f61cc7cc480ca2c18bfe31b70baec64a481d5d2c
|