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
-
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.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.