Python Incremental Snapshot Backup Prompt
Build a Python backup tool that creates incremental, hardlink-based snapshots of a directory, prunes by retention policy, and verifies integrity.
- Target user
- Engineers building lightweight, dependency-free backups
- Difficulty
- Advanced
- Tools
- Claude, Cursor
The prompt
You are a senior backup engineer who designs space-efficient snapshot tooling that fails closed and never silently loses data. I will provide: - The source directory and the backup destination - The retention policy (e.g. keep 7 daily, 4 weekly) - Exclude patterns and whether to verify with hashes Your job: 1. **CLI** — `argparse` with `backup`, `prune`, `verify`, and `list` subcommands. 2. **Snapshot incrementally** — create a timestamped snapshot dir and hardlink unchanged files from the previous snapshot, copying only changed ones, so each snapshot looks complete but shares storage. 3. **Be atomic** — write into a `.partial` directory and rename to the final name only on full success, so an interrupted run never leaves a half-snapshot that looks valid. 4. **Prune by policy** — implement grandfather-father-son retention; never delete the most recent good snapshot, and refuse to prune below a configurable minimum. 5. **Verify** — `verify` re-hashes a snapshot against a stored manifest and exits non-zero on mismatch. 6. **Handle errors** — catch per-file errors, record them, and mark the snapshot incomplete rather than claiming success. 7. **Dry-run** — every destructive action supports `--dry-run`. Output as: (a) the full typed implementation, (b) a config example, (c) a systemd timer plus a restore one-liner. Treat the latest good snapshot as untouchable; prune only after a new snapshot is verified complete.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Asyncio TaskGroup Structured-Concurrency Python Script Prompt
Write a Python 3.11+ automation script that fans work out with asyncio.TaskGroup so failures cancel siblings cleanly, errors aggregate into an ExceptionGroup, and no task is ever silently orphaned.
-
Convert a Fragile Bash Pipeline to Python Prompt
Rewrite an overgrown, fragile Bash script full of pipes, subshells, and string parsing into a maintainable Python program with proper error handling, types, and tests.
-
Add Pytest Coverage to an Automation Script Prompt
Wrap an existing Python automation script in a pytest suite that mocks subprocess, network, filesystem, and clock side effects so the logic is tested fast and deterministically without touching real systems.
-
Idempotent Bulk File Rename & Migrate Tool Prompt
Write a Python tool that safely renames or relocates large batches of files using a rule set, with mandatory dry-run, collision detection, atomic moves, and an undo manifest so a bad run is reversible.
More Bash & Python Automation prompts & error guides
Browse every Bash & Python Automation prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.