• Add GitHub Actions workflow (Ubuntu, Python 3.10–3.12) • Add Makefile (test + pkgmgr install note) • Add requirements.yml (pkgmgr: dirval) • Replace shell scripts with parallel validator main.py using dirval • Add unit tests with fake dirval and timeouts • Update README to new repo name and pkgmgr alias 'cleanback' • Add .gitignore for __pycache__ Conversation context: https://chatgpt.com/share/68c309bf-8818-800f-84d9-c4aa74a4544c
Cleanup Failed Backups (cleanback) 🚮⚡
Repository: https://github.com/kevinveenbirkenbach/cleanup-failed-backups
This tool validates and (optionally) cleans up failed Docker backup directories.
It scans backup folders under /Backups, uses dirval to validate each subdirectory, and lets you delete the ones that fail validation. Validation runs in parallel for performance; deletions are controlled and can be interactive or automatic.
✨ Highlights
- Parallel validation of backup subdirectories
- Uses dirval(directory-validator) via CLI for robust validation
- Interactive or non-interactive deletion flow (--yes)
- Supports validating a single backup ID or all backups
📦 Installation
This project is installable via pkgmgr (Kevin’s package manager).
New pkgmgr alias: cleanback
# Install pkgmgr first (if you don't have it):
# https://github.com/kevinveenbirkenbach/package-manager
pkgmgr install cleanback
dirvalis declared as a dependency (seerequirements.yml) and will be resolved by pkgmgr.
🔧 Requirements
- Python 3.8+
- dirvalavailable on PATH (resolved automatically by- pkgmgr install cleanback)
- Access to /Backupsdirectory tree
🚀 Usage
The executable is main.py:
# Validate a single backup ID (under /Backups/<ID>/backup-docker-to-local)
python3 main.py --id <ID>
# Validate ALL backup IDs under /Backups/*/backup-docker-to-local
python3 main.py --all
Common options
- --dirval-cmd <path-or-name>— command to run- dirval(default:- dirval)
- --workers <int>— parallel workers (default: CPU count, min 2)
- --timeout <seconds>— per-directory validation timeout (float supported; default: 300.0)
- --yes— non-interactive: auto-delete directories that fail validation
Examples
# Validate a single backup and prompt for deletions on failures
python3 main.py --id 2024-09-01T12-00-00
# Validate everything with 8 workers and auto-delete failures
python3 main.py --all --workers 8 --yes
# Use a custom dirval binary and shorter timeout
python3 main.py --all --dirval-cmd /usr/local/bin/dirval --timeout 5.0
🧪 Tests
make test
This runs the unit tests in test.py. Tests create a temporary /Backups-like tree and a fake dirval to simulate success/failure/timeout behavior.
📁 Project Layout
- main.py— CLI entry point (parallel validator + cleanup)
- test.py— unit tests
- requirements.yml—- pkgmgrdependencies (includes- dirval)
- Makefile—- make testand an informational- make install
🪪 License
This project is licensed under the GNU Affero General Public License v3.0. See the LICENSE file for details.
👤 Author
Kevin Veen-Birkenbach 🌐 https://www.veen.world 📧 kevin@veen.world