Backup with restic
Data Safe
Many users still find it difficult to regularly back up their data. Thanks to restic, and its graphical front end, Restatic, a backup is quite easy to manage – even for a beginner.
Creating data backups for emergencies has always been one of the most unpopular tasks in the home office. The available applications mostly target enterprise use and spoil the fun with feature overkill, or they are simply too complicated to use for occasional backups. A small command-line program by the name of restic [1] proves that there is another way, and it is suitable for many different scenarios.
Restatic is a graphical user interface (GUI) for restic designed for home users who don't want to mess with a command-line interface. The Restatic front end is currently under development, and you'll need to install it separately.
Restic can store data on the local PC, as well as on a computer on the home network or in the cloud. It encrypts all the data with AES256 regardless of where they are stored, ruling out viewing by unauthorized third parties. In addition, the software is extremely fast as it eliminates any graphical overhead, and this makes it interesting for occasional users, too.
You can pick up restic either from the project's website or from the software archives of almost all the major distributions. Since the application is written in Go, you need a compiler to install it; on Debian/Ubuntu and its derivatives you will find this in the golang-go package. After the install, you call the software with the restic
command at the prompt to see an overview of the available parameters.
Backup
A local backup with restic requires only two steps. First, create a repository for the datasets to be archived (Listing 1, line 1), and then save the data in the newly created archive (line 2).
Listing 1
Creating a Repository
When creating the archive, you can specify a password for the repository, which you must confirm by retyping. During the backup, restic may request the password for the newly created archive and will then start to store the specified data in the repository in an encrypted format. While doing so, the software displays the progress of the storage process as a percentage and in absolute figures (Figure 1).
To store the backup on a remote server, use the SFTP protocol. Instead of the local backup directory, enter the server name, including the target path to be created on it, at the command line. The further operating steps, including password entry, are like those on a local system.
For each new backup, restic creates a new backup file within the archive path below snapshots/
. To display its content, use the command from line 3 of Listing 1. The corresponding table shows the ID number of the backup, as well as the host. The tool lists the backup's original path in full, so that you can quickly see which backup it is. If an archive with a directory tree of the same name contains data from different host computers, restic lists it in order, but does not display individual files in any case.
Granular Details
To view individual files and directory structures in a repository, you first need to mount the repository. This feature lets you copy individual files from a backup instead of restoring all the data. To mount a backup, it is best to use a temporary directory with an arbitrary name as the target.
If the directory does not exist, restic asks if it should create the directory when it calls the mount
command (Listing 1, line 4) and mounts the target directory after you confirm. However, it mounts the temporary directories as read-only, so your options for working with the files in the directories are limited. In addition, the command for mounting the backup remains active in the terminal, so all activities performed with the files have to be carried out in a separate tab or window. After you finish this work, you need to unmount the temporary directory; restic will not quit until you do this.
Additional parameters let users perform various additional tasks with the backed up datasets. For example, you can remove individual backups from a repository using the forget
option. This helps to keep the archive clean by removing obsolete individual backups, especially from scheduled backup runs.
Since restic always creates full backups, the differences between individual backups cannot be seen at first glance. The diff
option helps users here; it shows differences in the data between two backups. check
lets you verify the data integrity.
The exact syntax for the use of individual subcommands is revealed by entering the following command at the prompt:
restic <Command> --help
The software then displays detailed descriptions for using the option in question.
Restore
To restore a backup on demand, you will need the ID number – assuming you have several backups. To do this, first display the existing backups (Listing 1, line 3). From the full file paths that are displayed, you can see which backup has which ID number. Then specify the command from Listing 2 to restore a backup. Restic now returns the specified backup to the specified target path, automatically creating the corresponding subdirectory if it does not exist (Figure 2).
Listing 2
Restoring a Backup
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.