What are the best practices for snapshotting zvol based VMs

jasonhh

New Member
Mar 18, 2022
3
1
3
I might not be searching the correct terms, but I haven't really found any information on ways to manage snapshots for VMs running in zvols on ZFS.
- Our system runs VMs on a zpool, and I let PVE automatically create a new zvol for each VM.
- I have setup zfs-auto-snapshot to take incremental snapshots of everything.
- The Web GUI based backup utility doesn't work with ZFS to the best of my understanding.

What is the best practice to have the ability to rollback the zvols?
- I know for systems with a database we should flush the DB before taking a snapshot.
- should we use the qmp freeze command before taking a ZFS snapshot?
- If there is a particular snapshot I want to keep, should I just hold the snapshot?
 
- I have setup zfs-auto-snapshot to take incremental snapshots of everything.
- should we use the qmp freeze command before taking a ZFS snapshot?
I would use cv4pve-autosnap and not zfs-auto-snapshot. zfs-auto-snapshot will do snapshots directly on the ZFS level and cv4pve-autosnap will use the PVE API to create snapshots. Only when using the PVE API you will get consistent snapshots as this will additionally use the qemu guest agent to make sure the guest dropped all caches (fsfreeze) before creating the snapshot. And there are some other benefits like it is possible to dump the RAM so you can rollback into a running VM (so your guests applications won't crash) and snapshots will show up in the webUIs task history.
What is the best practice to have the ability to rollback the zvols?
- I know for systems with a database we should flush the DB before taking a snapshot.
- If there is a particular snapshot I want to keep, should I just hold the snapshot?
Don't use snapshots for long term backups. The older your snapshots get, the more space they will consume. Snapshots can easily consume a multiple of the space of the actual data that you snapshotted. I would use PBS in case you want store something for the long term. If you need a restore point every several minutes or hours snapshots are fine. For everything on a daily/weekly scale I would use BPS "snapshot" mode backups.

Also keep in mind that PVE only allows you to rollback to the latest zfs snapshot. If you want to rollback to an earlier snapshot you need to manually delete all snapshots after that first. That is to prevent that users accidently loose data. Because with ZFS snapshots are a oneway road. Once you roll back everything, after that snapshot was taken, will be deleted. So there is no way back.
 
Last edited:
  • Like
Reactions: jasonhh

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!