pve-bindsnap: snapshot LXC containers that have bind/device mounts (open source)

bitranox

Member
Oct 11, 2024
97
49
18
Hi all,

Like a lot of people here, I ran into the wall where a container with a bind mount cannot be snapshotted: the Snapshot button greys out and pct refuses. The usual answers are to switch to lxc.mount.entry, or to remove the mounts, snapshot, and add a handful of host binds.

So I wrote a small overlay that fixes the snapshot path itself. Open source (AGPL-3.0):

https://github.com/bitranox/pve-bindsnap

What it does:
- Lets you snapshot, roll back and delete snapshots of containers that have bind or device mounts.
- Only the managed volumes (rootfs and volume-type mpN) go into the snapshot. The bind and device mounts are skipped and the host data behind them is never touched.
- You can also keep specific managed volumes out of a snapshot, with a per-mountpoint exclude set once in the container Notes (or per snapshot).
Handy for a large or throwaway mpN you do not want in every snapshot.
- Backups (vzdump) are not affected. It only changes the snapshot code path.

A few safety details, since this does touch the LXC stack:
- It only acts on containers that actually have bind/device mounts. Normal containers snapshot exactly as before.
- It refuses to run on pve-container builds it has not been checked against (a content checksum, not a version string). Right now that is 6.1.10. On another build you can
opt in with a keyword, and ideally report back so the build can be added to the known-good list.
- There is an opt-in keyword for snapshotting a running container, which takes the brief fs-freeze.

It is release 1.0.0 and runs in my own production cluster, but it has only been verified on pve-container 6.1.10 so far. I would be glad if a few more people tried it on other builds and reported what they see.
It also works as-is with cv4pve-autosnap and other API based tools, because it loads under the API rather than wrapping pct.

Feedback and bug reports welcome.