[TUTORIAL] ZFS not most recent snapshot bypass

H4R0

Well-Known Member
Apr 5, 2020
616
143
48
In case you use autosnapshot or other tools to do periodic zfs snapshots and thus can't use the roolback feature of pve.

1613518747623.png

This patch enforces the rollback, execute as root in terminal:
Code:
cat << 'EOF' > /etc/cron.hourly/proxmox-zfs-rollback-force
#!/bin/bash
FILE="/usr/share/perl5/PVE/Storage/ZFSPoolPlugin.pm"
grep "'rollback', \"" $FILE >/dev/null && sed -i "s/'rollback', \"/'rollback', '-rf', \"/g" $FILE && sed -i "s/if \$snap ne \$recentsnap;/if 0;/g" $FILE && systemctl restart pvedaemon || exit 0
EOF

chmod +x /etc/cron.hourly/proxmox-zfs-rollback-force

bash /etc/cron.hourly/proxmox-zfs-rollback-force

Note: A rollback deletes all snapshots taken afterwards
 
Last edited:
  • Like
Reactions: Dunuin