Problem/Justification
Currently, there is no simple way of backing up to a local SATA or USB HDD.
It is quite cumbersome to use cold storage as a backup solution. With cold storage I mean drives which are stored offline somewhere off site.
Correct me if I am wrong or if I am missing something.
Let me start by describing how I used to do my backups:
- Have a couple of HDD’s stored off site on a shelf.
- Bring them to my NAS in more or less irregular intervals.
- Connect via SATA hot swap.
- Import the ZFS pool in the TrueNAS webui.
- Run a scrub if it has been a while since the last backup.
- Create manual snapshot with a specific naming scheme of all pools I want to back up.
- Manually run a replication task to copy the snapshots to the backup hdd.
- Manually delete all old snapshots, since there is no option to only keep a certain number of snaphots.
There are only options to delete snapshots based on age. However, this is not an option for me, since I only create backups in irregular intervals. - Then I export the pool via the webui, take out the hot swap sata drive and take it off site again.
- Rotate the HDD’s and take another one next time. There should be at least one stored off site at all times.
Since this was too much of a hassle for me, I decided to write a script that does all of that for me.
However, it is not 100% reliable and I would love to see such a feature implemented similarly in the webui.
I think it could be beneficial to a lot more people. All the threads I have read online about backing up to a local sata or USB HDD don’t give satisfactory and easy answers.
Here is a description of how my script works. The feature could be implemented similarly:
- Script gets started automatically on drive insertion by a udev rule.
- There is a config file with a list of source pools, destination pools and corresponding serials of the backup drive.
- If the serial number of the inserted drive matches one in the list, the script continues.
(All of this would not be needed in the feature implementation, since a button in the webui to manually start the backup process would be just fine too.) - The backup pool is imported
- The age of the latest snapshot is checked. If it is older than some threshold, a scrub is run.
- If the scrub succeeds, snapshots of the specified datasets are taken with a naming scheme.
- Snapshots are copied to the backup drive. (incremental, if not the first time. This is also why a scrub is needed)
- Old snapshots are deleted. Only a certain number of snapshots is kept at a time.
- Pool is exported
- Log is sent via email (this would not be needed in a real implementaion of this feature)
It would be great to have a UI element to configure, start and monitor such a backup process:
-Configure which datasets / pools should be copied to which backup HDD.
-Allow for the execution of custom scripts before and after the backup process? For example to create a truenas config backup or stop VM’s before backing up.
-Snaphot retention based on number of snapshots (not on age). This is required because of the irregular backup intervals. And in order to copy an incremental snapshot from source to destination, there needs to be the same base on both disks.
-Scrub and SMART test based on time since last backup to ensure integrity of backup pool before copying new snapshots.
Please tell me what you think about such an idea.