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
-
Gnome 48 Alpha Ready for Testing
The latest Gnome desktop alpha is now available with plenty of new features and improvements.
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.