Recently I covered a few topics on backups, recovery, and cloning of disks. Some of the readers came up with a few questions. One of them was that BTRFS and Rsync tries to backup using a tool like Grsync, Duplicity, or Timeshift. In this guide, we will discuss what are the technical differences between both and which one is better than the other. I am using Debian 10 Buster Edition for this guide. You don’t need to also use the same.
Rsync is a utility with small footprints on disk for backing up local and syncing remote files from servers to your local disk. Not only it supports both MBR and GPT partitions, but also covers several file systems like Ext4.
When we take a backup using Rsync utility or using a third-party tool that works on top of Rsync, then common files are shared between the periodic backups. This helps to save enormous disk space.
Rsync can save data anywhere. It means if you have a different file system on your external disk than your production system, Rsync will save the data on both. The greatest disadvantage of Rsync is that it is slightly slower than BTRFS.
Demo 1. Push Operation
Here is how push operation is performed using Rsync:
$ rsync local_file_path [email protected]:remote_file_path
In this example, we are pushing a local directory to a remote folder.
There is one more demo of pulling a file or directory from a remote server to a local system.
Demo 2. Pull Operation
$ rsync [email protected]:remote_file_path local_file_path
In this operation, a user is simply pulling a remote file to a local machine creating a nice backup.
Demo 3. Save Some Bandwidth
Now I have a concern here. I want to save some bandwidth while creating local and remote backups. Rsync provides full control to perform such operations.
$ rsync -av -e ssh --max-size='1M' /src/ [email protected]:/path/to/dst/
In this example, I am clearly fetching only those files which are maximum of 1 MB size. This helps me avoid any large files available in my archives.
BTRFS stands for Better File System. Unlike Rsync, which is a program, BTRFS is a file system of its own. This is what makes the difference between them. Let us try to understand this with the following example:
If you formatted your disk with the BTRFS files system instead of Ext3 or Ext4 then you will be able to use the BTRFS method to save your data on the same disk.
Any backup taken using BTRFS saves time. It is faster because it is saving the data to a similar file system on Linux. If you do not have a BTRFS file system then you will have to create a BTRFS partition to keep your backups.
If you have your system set up for BTRFS then it is better to use the BTRFS backup option whenever it comes. Rsync would disappoint you in this scenario.
In the above discussion, we learned that BTRFS is not a backup system in context; rather it is a full-blown filesystem. Here is how to set it up on your device.
BTRFS doesn’t come preinstalled, so you will have to install it manually usually.
Once installed, you will have the opportunity to run BTRFS on your system, for example:
Example 1. Take a snapshot of the system
$ btrfs subvolume snapshot ‘/btrfs/SV1’ in ‘/btrfs/SV1-snap’
This will create a subvolume snapshot of your complete file system volume
Example 2. Take a read-only snapshot of the system
$ btrfs subvolume snapshot –r ‘/btrfs/SV1’ ‘/btrfs/SV1-rosnap’
Both of the examples show that one program is copying whereas the other is creating storage blocks out of the available disks.
In this guide, we discussed how Rsync and BTRFS differ from each other. One is a program to create backups and the other is a whole file system. I hope this clears the concept, and now you will be using both utilities in a much efficient way.