I’ve changed my media storage system from the Linux setup I outlined earlier to FreeNAS. In the process of the transition, I built an entirely new server using a Norco 4224 as the case and a Xeon processor with ECC. Since FreeNAS makes ZFS so easy and doesn’t suffer from several of the problems of ZFS on Linux, I elected to use this OS for my storage going forth. The only issue I had to resolve was how I would handle backups.
Since I now have a hot-swap case, I decided I’d use some bays to hold the backup drives. I bought a few extra drive caddies since I wanted to have 2 sets of backups. It seems rare that anyone uses another pool on the same machine for backups and so I figured I’d outline the steps necessary to do internal backups. It’s pretty much the same as replicating to another machine but it is replicating to localhost and not remote:
- Create periodic snapshot tasks on datasets you wish to backup. These can be recursive.
- Create the backup pool. I elected to use encryption so I backed up the geli key for this pool as well as the geli headers. If you choose to use encryption and want to detach a pool, you must backup the geli key.
- Go to the replication tasks and copy the public key.
- Go to the users, edit the root user, and paste the replication key there.
- Go back to replication tasks, and create a task for each dataset to backup. Set the remote hostname to localhost and the remote volume to the backup pool name
- Turn off Replication Stream Compression and set Encryption Cipher to Fast in each replication task. These options speed up the replication since bandwidth usage and encryption are not as critical when talking to localhost.
That sets up the backup pool. Repeat for any other sets. I’ve not found anyone who has described how to do multiple backup sets with FreeNAS so I figured it out myself. It cannot backup to both backups simultaneously, but it can be manually switched between the two. Since I have 2 sets of backups, called backup1 and backup2, I needed a way to swap out which backup pool was currently used. The steps for a swap from backup1 to backup2 are:
- Create recursive snapshot named backup1 on the datasets which are backed up. This is to ensure it has a point to backup from when backup1 is re-inserted. At its most recent version, this is not a requirement for ZFS but I do not know if FreeNAS has this ability yet so I make this snapshot for safety.
- Wait for these snapshots to be replicated to backup1
- Disable all the replication tasks.
- Detach the backup1 pool. Ensure you have the geli key backed up before completing this operation.
- Swap the drives for backup1 and backup2.
- Attach backup2. If it is encrypted, you must provide the geli key for backup2.
- Re-enable replication tasks and set the destination pool to backup2.
- Set the scrubs on the backup pool appropriately. I use the 2nd and 16th of the month.
- Update the smart tests to include the drives in the backup2 pool.
- Wait for replication to complete.
- Check differences between backup2 snapshot and current. Unfortunately, zfs diff doesn’t always tell you about files which are deleted, so rsync can also be used here: rsync -vahn –delete /mnt/${POOL}/"${FS}"/ /mnt/${POOL}/"${FS}"/.zfs/snapshot/backup2*/.
- When satisfied with the differences, remove the backup2 snapshot from the main pool’s datasets.
That’s my procedure for handling two backups within the same machine as the main pool. I tend to swap my backups about once a month and the intent is to keep at least one off-site at all times. Hopefully this is helpful to someone out there wanting the same.
Legacy Comments:
JohnPPI - Aug 6, 2016
Thank you! I was having a hard time with this!
Astrodonkey - Oct 7, 2017
Much appreciated. Was having trouble with this.
s.p - May 26, 2017
Thank you! It was really helpful
Eric Smith - Oct 29, 2019
so helpful, went round and round until I read your article about pasting host key in as root public key and done! thanks for taking the time to write this
sh3t0r - Nov 29, 2019
You are my hero.