How do I set up ZFS for rdiff-backup?
ZFS is a relatively new file system available for the Linux platform. Its popularity is gaining speed thanks to its great management flexibility and its resilience. To learn more about the benefits of ZFS, check out our previous article.
Further to our article on the benefits of ZFS for rdiff-backup, you will find herewith more technical information which explains the best configuration practices for ZFS when used with rdiff-backup.
For starters
It is highly recommended to create a specific dataset for storing rdiff-backup deposits. You will then be able to adjust the configuration settings of this dataset without affecting the configuration of the rest of the system.
To create a new dataset, run the following command where rpool is your zfspool.
sudo zfs create rpool/backups
This will create a default dataset configuration setting that you can adjust later.
Activate compression
As mentioned in our previous article, one of the great advantages of ZFS is its ability to directly compress data. First, you will be surprised to find that lz4 compression improves reading and writing performance.12
To activate compression, you need to change compression properties.
zfs set compression=lz4 rpool/backups
Be sure to use lz4 compression mode to optimize performance since other compression modes are more draining on CPU resources.
Once activated, the new data written on the disk will then be compressed. Existing disk data will retain its original compression mode.
If you want ZFS to do all the compression work, it is recommended to deactivate rdiff-backup compression by changing your command line as follows:
rdiff-backup --no-compression ...
Implementing this strategy can be complex, as you will need to change the command on the client side or on the server side depending on the way you operate. Should you have any questions about this, please leave a message in the comments.
If you use Minarca, you can easily implement this strategy by changing the configuration setting to RDIFFBACKUP_ARGS=--no-compression in /etc/minarca/minarca-shell.conf.
primarycache & secondarycache
ZFS is known for its high-performance cached system called Adaptive Replacement Cache (ARC). This system provides great flexibility since it adjusts to different deployment needs. As part of rdiff-backup, it is best to set up the ZFS cache to only store metadata. To quickly activate this feature, the primarycache and secondarycache value must be changed as follows:
sudo zfs set primarycache=metadata rpool/backups
sudo zfs set secondarycache=metadata rpool/backups
Deduplication
ZFS also allows you to enable an interesting data deduplication feature. Should two blocks of data be identical, ZFS can only store the same block of data on the disk one time, thus avoiding multiple storage of the same data. This feature is particularly interesting if you back up system files from multiple machines with similar operating systems.
However, ZFS uses much more RAM. It would be wise to measure the real impact of this feature in the lab for your type of data backup.
sudo zfs set dedup=on rpool/backups
utf8only
Although rdiff-backup supports the use of a UTF-8-character code restriction file system very well, it is highly recommended to enable non-UTF-8-character support in ZFS for compatibility purposes. This will allow you to safely copy your data from another file system. Moreover, this feature cannot be changed after the dataset is created. When you need to copy files with a non-UTF-8-character code, it will be too late to change this option.
sudo zfs create -o utf8only=off rpool/backups
Conclusion
ZFS is definitely a file system that you need to familiarize yourself with if you are a Linux platform manager. It will certainly change your management methodology. However, it is worth mentioning that that FreeBSD also offers advantages over the ZFS On Linux version. We encourage you to find out about this!
1. ZFS Compression - A Win-Win, https://blogs.oracle.com/solaris/zfs-compression-a-win-win-v2
2. The Case for Using ZFS Compression, https://www.servethehome.com/the-case-for-using-zfs-compression/