This is an automated archive made by the Lemmit Bot.
The original was posted on /r/unraid by /u/bear_84 on 2023-09-06 11:30:22.
TL;DR should I stop database containers before creating a ZFS snapshot of them? How?
Ever since I upgraded to 6.12.3, I have been playing around with ZFS. I recently upgraded my SSD drives, so I figured I would upgrade my 2 cache pools to ZFS. Works great!
One of the pools contains my appdata, and I want that to be as safe as possible. The pool itself is mirrored, so that’s one base covered.
Next, I want to do a daily snapshot and backup of my appdata to the array. To achieve this, I have converted the appdata folders to datasets datasets, and I set up replication of those datasets to one of my array drives, that I also converted to ZFS. So 2 copies, with snapshots, but still on the same server. Safe from my own screwups, but not from catastrophic server failure.
Next up: offsite backup. I opted for cloud storage, since setting up an offsite server with ZFS replication was either too expensive (zfs.rent, rsync.net) or cumbersome (separate unRAID at a friends house or so). So I opened an account at Wasabi, and configured Duplicacy to backup the appdata folder on the array drive to Wasabi on a weekly basis.
This seemed to work great, until I actually messed something up with the config of one of my Postgres databases, figuring I could just restore a snapshot if something went wrong. After the rollback, my database was corrupt :o
Thinking back, this makes sense, since a snapshot of a database is not guaranteed to be ‘complete’ since some data can still be floating around in memory. This is why plugins like Backup/Restore appdata will stop containers before backing them up.
But u/spaceinvaderone 's script to do the replication provides no option to stop containers before creating the snapshots (even though the script to convert folders to datasets DOES have this option).
Now I’m worried that I’m creating useless snapshots and backups. Any advice on how to tackle ZFS snapshots of live databases?