Looking for a file backup solution for your Linux system? Well, there are many great backup software available for Linux. One of my favorite among them is the diff backup. Rdiff is a command-line backup tool for Linux that you can use to back up your files to both local and remote backup storage. It’s not a fancy kind of backup software but it has a great performance to get the things done efficiently.
Main Rdiff Features
- Create Mirror. Rdiff-backup will create exact copy of your source directory. In case your source directory crashes, you can easily mount and gain all your files back from the backup.
- Incremental Backup. Rdiff-backup will not create a traditional mirror backup. It will keeps the incremental backup of your files. It will also save you a lot of storage/space compared to full backup.
- Bandwidth Efficient. This Linux backup software utilize librsyncl which is known as a bandwidth efficient tool for backup.
For more information about the features of Rdiff, please visit their official website.
Install rdiff-backup on Ubuntu, Debian and Linux Mint
You can install rdiff-backup on Debian based Linux such as Ubuntu or Linux Mint using this command.
sudo apt install rdiff-backup
How to Use rdiff-backup to backup your files
Backup to local directory
If you want to backup to a local directory, simply use the following syntax
rdiff-backup source destination
For example, I would like to backup my home directory to a folder /backup. So, the full command will looks like this
rdiff-backup /home/dhani/ /backup
Backup to Remote directory via SSH
The following scenario will backup to the remote directory via SSH. If you want to backup to a remote Linux PC, make sure you also have rdiff-backup installed on your remote PC.
rdiff-backup source hostname::/destination
rdiff-backup /home/dhani/ manjaro.site::/backup
Backup from remote directory to local directory
Same as backing up from local to remote directory, both PC or system must have rdiff-backup installed. To backup from remote to local directory, use this syntax
The command will backup the remote directory (/var/www) to my local directory /backup-website.
How to Restore Data
Restoring data from the backup storage is also pretty simple.
Restore from a local backup
To restore from a local backup, we can use the cp command as follow:
cp -a backup-dir restore-dir
cp -a /backup-test /temp
This will restore from the folder /backup-test to /temp folder.
Backup from a Remote location via SSH
The following scenario will restore the data from a remote location to a local folder. In this case, we cannot use cp command to copy the files from a different machine. So, we will use the rdiff-backup command to restore files.
rdiff-backup --restore-as-of now host.net::/remote-dir/file local-dir/file
Please note that the option –restore-as-of will initiate the restore command. And “now” option will restore from the most recent backup.
For more information, please visit the official rdiff-backup documentation.