Podman Volume Backup & Restore Prompt
Build a tested backup and restore procedure for Podman named volumes and container state that survives rootless UID mapping and SELinux relabeling.
- Target user
- SREs and sysadmins responsible for Podman-hosted stateful services
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior systems engineer who considers a backup unproven until a restore has been performed on a different host. I will provide some or all of: - `podman volume ls` and `podman volume inspect` output for the volumes in scope - What the volumes hold: a database data directory, uploaded files, config, or cache - How the containers run: rootless or rootful, ad hoc or Quadlet units, standalone or in a pod - The recovery objectives: acceptable data loss window and acceptable downtime - Where backups go and how long they must be retained, plus whether restores may target a different host or user Your job: 1. **Classify each volume** — separate volumes that must be application-consistent (databases, anything with a write-ahead log or index) from volumes where a file-level copy is sufficient (static uploads, generated caches). State plainly that copying a live database data directory produces a backup that may not restore, and that cache volumes usually should not be backed up at all. 2. **Choose the capture method per class** — for application-consistent data, prefer the application's own dump run inside the container (`podman exec` into the tool, streaming to stdout) or a quiesce-then-copy with the container stopped. For file-level data, use `podman volume export <name>` to produce a tar stream, or a helper container that mounts the volume read-only and tars it. Give the exact commands for each volume in scope. 3. **Capture the definitions, not just the bytes** — a restore needs the volume to be recreated with the right driver and options and the container to be recreated with the right image, mounts, env, secrets, and network. Prescribe capturing `podman volume inspect`, the Quadlet unit files, and the image digest alongside the data, and note that `podman inspect` on a container is a description, not a reproducible spec. 4. **Decide about container state** — explain where `podman container checkpoint`/`restore` (CRIU-based) genuinely helps, such as migrating a long-running process, and where it is the wrong tool because the state that matters lives in a volume. Cover `--export` for a portable checkpoint archive and its constraints honestly. 5. **Write the restore procedure** — give the ordered steps: create the volume, `podman volume import` the archive (noting that the target volume must already exist), restore ownership, recreate the container or `systemctl --user start` the Quadlet unit, and run an application-level integrity check. Number the steps so they are runnable under pressure. 6. **Handle ownership and labels on restore** — address the two failures that break restores across hosts: file ownership landing outside the target user's mapped range (fix with the `:U` mount option or `podman unshare chown`), and SELinux denials on restored paths (fix with `:z`/`:Z` mount options or an explicit `restorecon`). Say which applies when restoring as a different user than the backup was taken by. 7. **Automate and schedule** — supply a systemd service plus timer (user-level for rootless) that runs the backup, writes to the destination, prunes by retention policy, and exits non-zero on failure so the failure is visible. Include `OnCalendar=`, `Persistent=true`, and where output goes. 8. **Prove it** — define a restore drill: restore to a scratch host or a differently named volume, start the workload against it, run a specific data-integrity assertion, and record the measured restore duration against the stated objective. Output as: (a) per-volume classification, (b) capture commands per volume, (c) what else to capture beyond data, (d) checkpoint/restore applicability, (e) numbered restore runbook, (f) ownership and SELinux handling, (g) systemd service and timer, (h) restore drill definition. Never present a running-database volume copy as a valid backup. If application-consistent capture is not possible for a given volume, say what the restore risk is in concrete terms rather than qualifying it away.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
This prompt treats a backup as unproven until a restore has succeeded on a different host, and every step is arranged to support that claim. It starts by classifying volumes rather than backing them all up, because the correct treatment differs sharply: databases and anything with a write-ahead log need application-consistent capture, static uploads are fine with a file-level copy, and cache volumes usually should not be backed up at all. Skipping that classification is how teams end up with a large, regular, useless backup of a live database directory.
Step three addresses the failure that only appears during an actual recovery. The bytes are rarely the hard part — recreating the volume with the right driver and options, and the container with the right image digest, mounts, secrets, and network, is. Prescribing capture of podman volume inspect, the Quadlet units, and the image digest alongside the data, and noting explicitly that podman inspect on a container is a description rather than a reproducible spec, closes the gap between having the data and being able to run against it.
The ownership and SELinux step exists because cross-host restores fail on exactly two things, and both are invisible until the workload refuses to start: files landing outside the target user’s mapped range, and denials on restored paths. Pairing that with a scheduled systemd timer that exits non-zero on failure, and a restore drill with a measured duration against the stated objective, is what makes the strategy something you can point at during an audit rather than a script nobody has run in anger.
Related prompts
-
Podman SELinux Volume Labeling Strategy Prompt
Decide between :z, :Z, and permanent host relabeling for every Podman mount so containers get access without weakening SELinux or corrupting host directory labels.
-
Podman Host Drift & Storage Reclamation Audit Prompt
Audit a running Podman host for configuration drift from its declared units, orphaned images and containers, and reclaimable storage, then produce a safe cleanup plan.
-
Volume Mount & Permission Troubleshooting Prompt
Fix Docker volume problems: permission-denied on bind mounts, UID/GID mismatch between host and container, data not persisting, or a named volume masking image content.
-
Docker to Podman Team Migration Plan Prompt
Produce a phased Docker-to-Podman migration plan covering socket compatibility, CI impact, rootless gaps, and the developer workflow changes a team will actually hit.
More Podman prompts & error guides
Browse every Podman 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.