1. Overview

If we want to keep our data safe in case of a system failure, a data backup is one of the first things that we can perform. There are a lot of tools available on the Internet that back up with precision and also guarantee the safety of the data. Such tools enable us to configure many aspects of the process:

  • backup type
  • backup duration
  • specific data
  • backup activity log

In this tutorial, we’ll take a look at a list of tools that we can use for backing up data. We’ll have a detailed discussion on what they offer, how to install them, and how to use these tools for backup creation and data restoration.

In terms of installation, we’ll use the aptdnf, and yum commands, which are package managers used for installing tools on different distributions. Moreover, we have to be a root user to install these, so we’ll use the sudo command.

2. BorgBackup

BorgBackup is a useful tool that provides an efficient and safe way to perform data backup. This tool makes use of data deduplication to offer daily backups without consuming too much space. Additionally, BorgBackup uses authenticated encryption to make itself capable of backing up data to untrusted targets.

In summary, BorgBackup offers many useful features:

  • compression methods to minimize the size of the backup and perform incremental backups
  • data integrity checks and snapshot support to ensure the privacy, integrity, and dependability of the backups
  • detect unmodified files and execute local caching of the backup file index data for high-speed backups

Let’s begin by installing the tool.

2.1. Installation

If we’re installing BorgBackup on a Debian-based distribution such as Ubuntu, we’ll use the apt command:

$ sudo apt install borgbackup

On Fedora-based distributions such as RHEL, we use the dnf command:

$ sudo dnf install borgbackup

In the case of CentOS, we employ yum:

$ sudo yum install borgbackup

Now, we should have the borg command available.

2.2. Creating a Backup

When BorgBackup creates a backup file, we store it in a directory. So, the first step in this process is to create a directory using the mkdir command:

$ mkdir backup

Secondly, let’s use the borg init command to initialize the backup path as a repository:

$ borg init --encryption=none /mnt/backup

Above, /mnt/backup is the full path of backup. Additionally, we’ve used the –encryption option and set it to none, because we don’t want to encrypt the repository in this case.

Finally, let’s create a backup of a specific directory:

$ borg create /mnt/backup::archive /home/videos

Here, the borg create command creates a backup of the videos directory and stores it inside the backup directory with the name archive. The double colon (::) separates the backup location from the file name.

So, after creating a backup using BorgBackup, let’s see the process of restoring data.

2.3. Restoring Data

Firstly, we create a directory where we’ll extract all the data that’s present inside the backup file:

$ mkdir restore

Then, we’ll navigate to the restore directory using the cd command:

$ cd restore

The last step is to use the extract subcommand of borg:

$ borg extract /mnt/backup::archive

Here, borg extract extracts the contents of the archive file located inside the backup directory and stores the extracted data in the current working directory, i.e., restore. After the process is completed, we should be able to access all the backed-up data inside the directory that we’re currently in.

Let’s proceed to the next tool that helps with data backup.

3. rsync

rsync is another tool that we can use to back up data. It employs a delta-transfer mechanism, which enables the tool to perform high-speed synchronization of remote files after an initial run. This is possible because rsync only transfers the modifications that are made to the files that we’re backing up.

Let’s explore some features that make this tool special:

So, let’s begin by installing rsync.

3.1. Installation

In the case of Debian-based distributions such as Ubuntu, we use the common package manager:

$ sudo apt install rsync

Here, we’re installing rsync on Fedora-based distributions such as RHEL:

$ sudo dnf install rsync

On CentOS, we employ yum:

$ sudo yum install rsync

So, let’s move on to backup creation.

3.2. Creating a Backup

Again, the first step is to create a directory where we’ll store the backed-up data:

$ mkdir backup

Next, let’s perform a backup of all the data stored inside a particular directory:

$ rsync -aAX /mnt/videos/ /mnt/backup

Here, the rsync command backs up the data stored in the videos directory and stores it in backup. The trailing slash (/) after /mnt/videos tells rsync to avoid backing up the directory itself and only back up the contents inside the directory.

We’ve used the -A option to preserve the Access Control List (ACL) and the -X option to preserve the extended file attributes of the backup files. Moreover, we added the -a or –archive option to include all the contents inside the directory for backup as well as preserve attributes such as permissions, file ownerships, symbolic links, and more.

Let’s move on to the next section, where we’ll learn how to restore data using rsync.

3.3. Restoring Data

We’ll first create a directory where we’ll save the restored data:

$ mkdir restore

Then, we type the restore command:

$ rsync -aAX /mnt/backup /mnt/restore

Above, the rsync command restores all the data from the backup directory to the restore directory. In fact, when it comes to rsync, the main difference between the backup and restore commands is the order of the paths.

4. Timeshift

Timeshift is a tool that takes incremental snapshots to back up our system. The snapshots that the tool obtains can be used to restore the system to an earlier version.

Also, we can specify an interval for creating snapshots. Since the snapshots usually share common backup files, the space that they occupy can drastically decrease after the first one.

Timeshift offers a lot of features:

  • create an additional layer of backups by taking a snapshot whenever the system boots
  • supports the rsync and Btrfs methods for creating snapshots of the system
  • can use online or offline methods to restore a saved snapshot

Now, let’s begin by installing the tool on Linux.

4.1. Installation

On Debian-based distributions such as Ubuntu, we use apt:

$ sudo apt install timeshift

Fedora-based distributions like RHEL use dnf to install the timeshift package:

$ sudo dnf install timeshift

If we’re installing Timeshift on CentOS, we go with yum:

$ sudo yum install timeshift

Next, let’s see the process for creating a backup using Timeshift.

4.2. Creating a Backup

We can use a single command to create a backup with timeshift:

$ timeshift --create --comments "System Backup" --tags D

Here, the timeshift –create command takes a snapshot of the system and backs it up to a specific location, which can also be found in the output. Timeshift automatically names resulting files using the current date and time.

We’ve also used the –comments option, which takes a string as its input and attaches it as a metadata comment to the snapshot. As we can see, the comment is System Backup in this case. Finally, we also used the –tags option to set the frequency of the backups.

The letter D (daily) that we see instructs Timeshift to perform daily backups of the system.

Here’s the output that we’ll obtain:

Creating new snapshot...(RSYNC)
Saving to device: /dev/sdal, mounted at path: /
Syncing files with rsync...
Created control file: /timeshift/snapshots/2023-9-6_17-30-42/info.json
RSYNC Snapshot saved successfully (38s)
Tagged snapshot '2023-9-6_17-30-42': ondemand

As we can see above, Timeshift has successfully created a new snapshot and saved it to the timeshift directory, located in the /dev/sda1 filesystem.

4.3. Restoring Data

To begin with, we’ll create a directory for restoring backed-up data:

$ mkdir restore

To restore, let’s use the –restore option of timeshift:

$ timeshift --restore --snapshot '2023-9-6_17-30-42' --target /mnt/restore

Above, the timeshift –restore command extracts all the data from the previously created snapshot, which we referred to by using its name, 2023-9-6_17-30-42, as the value to the –snapshot option.

Furthermore, we’ve used –target to specify the restore location, which is the newly created directory restore in this case.

Upon entering the above command, we see a prompt:

Re-install GRUB2 bootloader? (recommended) (y/n): n

The GRUB2 bootloader is a tool that Timeshift uses for restoration. As we can see above, we’re asked for permission to re-install this tool, which indicates that it’s already installed. Hence, we won’t install it again, so we’ll enter n (no) in the terminal.

If we don’t want to give the permission and also want to avoid being asked for it, we can combine the –skip-grub option with the timeshift –restore command. This option instructs Timeshift to avoid prompting for GRUB2 bootloader re-installation.

So, we’ll see a summary of our request as well as a prompt:

Data will be modified on following devices:

Device     Mount
---------  -----
/dev/sdal  /


Please save your work and close all applications.
System will reboot after files are restored.

Continue with restore? (y/n): y

Above, Timeshift asks for permission to continue with the restoration process, which we have to provide in order to go further. Hence, we’ll type y (yes) in the terminal and hit Return.

Now that it has been granted permission, Timeshift extracts all the data from the snapshot and stores it inside the restore directory.

5. Conclusion

In this article, we discussed some tools that help with data backup on Linux. We’ve talked about the capabilities that each one possesses, gone through the installation processes, and also discussed the methods that we can use for creating a backup and restoring data using these tools.

In conclusion, regardless of their differences, each tool should do a decent job of backing up our system.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.