Taking backups of your data in Linux is likely one of the most important things you can do. No one can guarantee that a problem will not affect the service or network, even in a Cloud environment where content is distributed to other hosts. There are situations where you could lose your data. Usually, a Cloud solution is located in the same data centre. What would happen if that datacentre went on fire? Before you say that’s not going to happen. It already has. A few years ago, a well-known data centre in Europe caught fire after a fault on a server. Thousands of servers were lost and, many people lost data. Here we look at Linux backups with a focus on Rdiff-Backup and specifically, incremental backups.
Paid Linux Backup Solutions
Taking Linux backups doesn’t have to be complicated. There are some great free and paid programs out there to complete backups. Some of the popular paid solutions are R1backups and Jetbackup. Jetbackup is a great little program that now works on distributions without a control panel. Jetbackup has a number of advanced features like Snapshots and Incremental Backups. It’s currently priced at about $6 a month and is well worth the price tag if you want an Enterprise solution with great support.
Free Linux Backups Using Rdiff-Backup
On the other hand, Rdiff-Backups is a great free program that can give you a basic backup solution. Based on RSYNC, Rdiff-Backups will keep a mirror copy of your data. Each day Rdiff-Backup will copy only the data that has changed in your production environment. That data can be stored on an NFS server or in a remote location. Because it uses the RSYNC protocol, you don’t need any special server configurations. Let’s take a closer look at Rdiff-Backup.
Install Rdiff-Backup
Installing Rdiff-Backup is easy. Issue the commands below to get started and then we will take a look at using Rdiff-Backup.
# Debian / Ubuntu
apt install rdiff-backup
# CentOS 7 / RHEL
yum install yum-plugin-copr epel-release
yum copr enable frankcrawford/rdiff-backup
yum install rdiff-backup
# CentOS 8 / AlmaLinux
yum install dnf-plugins-core epel-release -y
dnf copr enable frankcrawford/rdiff-backup
yum install rdiff-backup
Now that Rdiff-Backup is installed we will take a quick look at the commands. Because this is a free piece of software, the documentation is not the best. Let’s imagine we have a production site in our NVMe VPS located at /home/website. So we want to make sure we have a copy of our data. We also have an NFS server mounted at /backup.
Local Rdiff-Backup
We can use Rdiff-Backup to take a copy of the data at /home/website and store it at /backup.
rdiff-backup /home/website /backup
Remote Rdiff-Backup
We can also use Rdiff-backup to send our files to a remote location. This is not as fast as an NFS solution.
rdiff-backup [email protected]::/home/website /backup
List Incremental Backups
After taking Linux backups, Rdiff-Backup stores the data in a folder called rdiff-backup-data. So you can see a full list of all increments using the –list-increments switch or just -l.
rdiff-backup -l /backup/rdiff-backup-data/increments

Notice the final line. Current mirror. This is the latest backup which is always stored in the /backup location. Older backups are moved to the /rdiff-backup-data/increments folder.
Restore Rdiff-Backups
Rdiff-Backup can automatically restore data. If you need to restore your whole site you can simply use the cp -R command to move the data from the /backup directory back to the /home/website location. You can also use the -r now switch
rdiff-backup -r /backup/rdiff-backup-data/increments /home/website
We can also tell rdiff-backup to restore our website back to how it was x days ago. We just specify the number of days to roll back to in the command.
rdiff-backup -r 5D /backup/rdiff-backup-data/increments /home/website
So that command would restore our website back to how it was 5 days ago. Finally, we can automate backups using a quick bash script and we can also tell rdiff-backups to remove backups older than x days.
Automate Backups & Remove Backups
So because you don’t want to be running the backup commands manually every day we can automate that. Let’s create a quick bash script.
nano /var/backup.sh
#!/bin/bash
rdiff-backup --force --print-statistics /home/website/ /backup/ 2>&1 > /var/log/backup.log
rdiff-backup --remove-older-than 1W /backup/rdiff-backup-data/increments 2>&1 > /var/log/remove-backup.log
Save and close the file and chmod it to 755.
chmod /var/backup.sh
So at this point you could run the script to confirm it works. Just call it in the command line with sh /var/backup.sh. But to automate it, just add a line to your crontab.
crontab -e
0 7 * * * sh /var/backup.sh > /dev/null 2>&1
And that cron would run backups at 7AM each morning. The backups would be incremental so, only the content that has changed will be copied to the backup location. Rdiff-Backup is a great tool for Linux Incremental backups. Its simple commands and powerful features will ensure your data security.
How was this article?
You might also like
More from Dedicated Servers
Enable Mod_RemoteIP – See Visitors Real IP address when using Cloudflare & Apache
If you are using Cloudflare on your Apache server you will always see Cloudflare IPs in your logs and not …
Fix 413 Request Entity Too Large Errors When Using NGINX
Just like Apache, NGINX imposes default limits on the size of files that can be uploaded. A 413 Request Entity …
Cloud-init Modules That Automate and Customize Deployments
Cloud-init is a popular way to automate deployments of instances in a cloud or none cloud environment. To save having …