Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Bash & Python Automation Difficulty: Advanced ClaudeCursor

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

More Bash & Python Automation prompts & error guides

Browse every Bash & Python Automation prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.