This tutorial will show you how to install and use the Restic Backup Utility on your machine.
Restic is a simple, feature-rich backup utility written in the Go Programming language. Restic is a modern, secure, and cross-platform software, making it usable on most of the main operating systems. It offers features such as the ability to verify backups, automate the backup process, and more.
To learn more about Restic, check the resource provided below:
Restic is available in major Linux distributions, and you can install it using simple commands using various package managers.
To install on Debian and other Debian based distributions, use the apt command:
On Manjaro and Arch distros, use the pacman command:
On the REHL family of distributions, you can use Copr repository or download the Restic binary.
Use wget to download the binary and move it to the bin directory:
[centos@centos8 ~]$ bzip2 -d restic_0.12.0_linux_amd64.bz2
[centos@centos8 ~]$ sudo mv restic_0.12.0_linux_amd64 restic && sudo mv restic /usr/bin
[centos@centos8 ~]$ sudo chmod a+x /usr/bin/restic
To create Restic backups, we need to initialize a directory that acts as the repository for Restic to store the files. A Restic repository can be both local or on a remote server or service.
Let us discuss how to initialize a local repository.
To initialize a local repository, use the Restic init command followed by — repo and the directory where you want to create the repository.
For example:
It is good to ensure that you remember the password; you will need it to access the files in the repository.
To create a remote repository on a server, use SFTP protocol. Before doing this, ensure the server is configured with SSH and Passwordless login as Restic will fail if prompted for a password. To learn how to use a public key for SSH logins, consider the following tutorial:
https://linuxhint.com/setup_ssh_without_passwords/
https://linuxhint.com/passwordless_login_ssh/
Once you have everything configured on your remote host, use the command below:
Now that we have the repositories set up on local and remote hosts, we can move on how to back up some data. In Restic, we call backups as snapshots.
To create a simple backup, use the command shown below:
The above command automatically creates a snapshot of the ~/archives directory and adds it to the repository we created earlier. You will notice the snapshot value is in the form of hexadecimal characters, thus making them easier and faster to identify.
Restic is a fast tool that can process many files in a few minutes with no strain on the computing resources. You can minimize the output of the Restic backup process by skipping the — verbose option.
It is good to note that Restic is very efficient, and it will skip duplicate files before adding them to the repository.
If Restic encounters a backed-up file, it scans the file to ensure that only the contents of the files get stored in the snapshot. It uses change detection mechanisms such as metadata to detect changes to a file.
Restic also allows you to add tags or additional information to a snapshot. Thus, allowing you to identify a snapshot easily. To add a tag, use the command as:
Then, you can reference a snapshot using the specified tags.
To view the snapshots in a repository, use the command:
sudo restic snapshots -r /srv/backup-repo
To remove a snapshot from a repository, use the forget command followed by the name or tag of the snapshot.
Use the command:
However, the forget command still reserves the data referenced by the files stored in the removed snapshot. You can remove the unreferenced data using the prune command.
Restoring files from a saved snapshot is simple. Use the command below to restore a backup:
In this tutorial, we have discussed how to install and use a Restic backup utility. This tutorial is a starter guide that teaches you how to perform basic backup and restore operations. To learn more about how to use the Restic backup tool, consider the documents in the resource provided below:
https://restic.readthedocs.io/en/latest/
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…
I don’t like my prompt, i want to change it. it has my username and…
Introduction: A Fragile Trust The Ruby ecosystem relies heavily on RubyGems.org as the central platform…