While we've all taken different journeys into home lab experiments, one of the mainstays is running your own NAS with an operating system like TrueNAS. You get to use your own choice of hardware, which can be significantly more potent than bespoke NAS enclosures, and you get more ways of doing things. Plus, you get to choose your file system, and if you're not picking ZFS, then I'm here to say you're wrong.
That's because between ZFS, virtualizing TrueNAS in Proxmox, and a handy backup tool, my TrueNAS is (nearly) immortal. It gives me two of the three pieces of a good 3-2-1 backup strategy and limits the effects of a power cut because of a beefy UPS battery. And while I could use Proxmox Backup Server for most things, or the inbuilt TrueNAS backup tools, I've found that a tool called Sanoid makes things even easier.
There's nothing worse than an apocryphal data event
But with ZFS you can recover thanks to snapshots
One of the best features of TrueNAS is using the ZFS file system, which has numerous NAS-centric features to save you from your worst inclinations. One of these is snapshots, which capture the full state of your NAS at that specific point in time. It's like how Time Machine works for macOS, or File History in Windows, except it's the entire contents of your NAS.
To reduce the storage load this would take, ZFS does incremental snapshots, so each new saved version only captures the changes since the last snapshot, and the system can combine them if the worst happens, and you need to re-image your NAS. One setup many TrueNAS users employ is to have an all-flash storage pool for current projects that's snapshotted to a HDD-based pool with more storage, so that you can work on the speedy storage while keeping your data safely on longer-term drives. And that's (mostly) what my setup is, except the two storage pools are on different machines.
Sanoid makes the process easier
Sanoid was designed to rebuild your storage when it all goes wrong. It's all too easy to CLI away large swathes of data when using *nix-based operating systems, and TrueNAS is no exception. And with ZFS already built in, it has the tools to create the necessary backups, but it does take some persuasion to get it working. The other thing is that any backup solution that doesn't take into account every change is going to miss things when you restore, and Sanoid is a backstop against that.
By taking ZFS snapshots on a rigorous policy timeline, Sanoid covers your bases with a comprehensive spread of backup fodder for when it all falls down. In the words of Jim Salter (the wise developer behind it), it "help[s] you put Humpty Dumpty back together," at least if you're dealing with ZFS file systems.
Sanoid Portable
My all-flash NAS gets snapshots sent to my larger NAS
Then my data is never far away from being restored
TrueNAS has it's own tools for handling ZFS snapshots, but they're not the easiest to use, and there's one tool that beats all others for ZFS snapshot management. That's Sanoid, which has a ton of power for a very straightforward tool. It's more a suite of scripts to handle ZFS snapshots, both locally and over the network if you prefer, and I can see why it's a community favorite.
Sanoid is really simple to use; all you need is a cron job to have it run every minute so it doesn't miss any snapshot schedules:
* * * * * TZ=UTC /usr/local/bin/sanoid --cron
And then one file in /etc/sanoid/sanoid.conf that
[data/home]
use_template = production
[data/images]
use_template = production
recursive = yes
process_children_only = yes
[data/images/win7]
hourly = 4
#############################
# templates below this line #
#############################
[template_production]
frequently = 0
hourly = 36
daily = 30
monthly = 3
yearly = 0
autosnap = yes
autoprune = yes
This sets the Sanoid script up to take 36 hourly, 30 daily, 3 monthly, and no yearly snapshots for every dataset you have set under data/images. But I already said that I'm also sending those snapshots to my second NAS, and Sanoid has a tool for that too.
It's called Syncoid, and it's incredibly simple to use. If your local system had multiple storage pools, you could run Syncoid as follows, which would copy your stack of ZFS snapshots to the second storage pool:
syncoid data/images/vm backup/images/vm
I've got mine to send images to my Synology NAS, which has much more space than my all-flash NAS. and Sanoid installed via Container Manager. The general syntax for that transfer is as follows:
syncoid data/images/vm root@synology_NAS:backup/images/vm
And to get that replicated ZFS filesystem back from my other NAS:
syncoid root@synology_NAS:data/images/vm backup/images/vm
And that's it, a robust snapshot system on TrueNAS that's then sent to a Synology NAS for longer-term storage.
It's not quite that simple on TrueNAS
Two things make it harder to use Sanoid on TrueNAS. One is the limitation of adding things from the package manager, but using Sanoid Portable gets past that because you're making a custom app for TrueNAS with no needed dependencies. And the other is that TrueNAS has a habit of overwriting any custom scripts or tweaks when you do OS updates, which is irritating. Still, this script on GitHub will fix that and make it easy to restore Sanoid to a working state once you've updated your NAS operating system.
There is one more piece of the puzzle
Since I'm passing relatively large amounts of data between my two NAS devices, I don't want to have a situation where power cuts out and data is lost on the wire, as it were. And that means I need a hefty UPS to ensure that my NAS devices and network don't go down. The thing is, most UPS units have relatively small batteries, and that's a problem when I've got my whole home lab plugged in. Larger battery devices often don't switch over fast enough for sensitive electronics, which need less than 10ms switchover to continue operating.
But it's not a problem for the 3,072Wh cells inside the EcoFlow portable power station. I can plug my PoE network stack, NAS units, and other home lab equipment in, and if a power outage happens, it switches as fast as the smaller UPS on my PC. It'll even send a standard NUT message out to turn off all my computers and servers gracefully once data transfer is over, and probably still have tons of power left to stream my media server over the network so we have entertainment until the power comes back on.
EcoFlow Delta 3 Ultra Plus
Between ZFS snapshots and a sturdy UPS, my TrueNAS is nearly immortal
It takes a combination of technologies to keep my NAS going strong, but when they're set up correctly, it would take a truly apocalyptic event to make me lose data. Between ZFS snapshots being taken on a regular schedule by Sanoid, which also handles all the trimming tasks to ensure those snapshots are as small as possible, and more battery capacity than I really need as a UPS, I know my data is as secure as it could be. The only missing part in this article is an off-site backup, which I haven't quite figured out yet.
