How To Set Up Open Source Backup Software Restic On Ubuntu

Take backup with open source backup software and store it locally or on external backends. Restic is cross-platform and supports multiple storage types.

Open Source Backup Software

A backup system is really important for both businesses and individuals. Data can be lost for various reasons such as a cyberattack, system failure, accidental removal, and many more. You should have a good backup strategy in place so that you can restore your data fast. This guide will show you how to install and utilize the open source backup software Restic on your Ubuntu server.

We have covered the following sections in this tutorial.

Prerequisites

Before installing Restic backup, you should meet the following requirements.

  • Machine with Ubuntu operating system
  • Non-root user with sudo privileges

What is Restic?

Restic is an open source backup software. It’s a free backup utility that’s fast, secure, and efficient. It’s cross-platform, so it’ll run on Linux, BSD, Mac OS X, and Windows. Restic is easy to run and does not require a server or a complicated configuration. It creates a backup of the modified data and allows users to restore it when necessary. Further, it provides a variety of storage options, including self-hosted and internet storage. Moreover, Restic uses robust cryptographic techniques to protect your data. Restic is not a simple file copying utility. It is primarily built on two concepts: snapshots and repositories. Restic saves the information as a snapshot, which is then saved in a repository. It is written in the Go programming language. The source code of this open source backup software is available at GitHub. However, you can find detailed documentation for the installation and usage.

Restic supports out-of-the-box following backends for backup storage.

  • Local directory
  • SFTP server (via SSH)
  • REST server
  • AWS S3
  • Minio Server
  • Wasabi
  • Alibaba Cloud
  • OpenStack Swift
  • BackBlaze B2
  • Microsoft Azure Blob Storage
  • Google Cloud Storage

You can use rclone for various backends in addition to the ones listed above.

Restic Installation

There are various ways to install Restic on your Ubuntu operating system. We will cover installation of Restic using Ubuntu package, docker, and source code.

Installing using Package

  • Run the command below to install Restic on Ubuntu.
$ sudo apt-get install restic

Installing using Docker

  • Get the Restic image from dockerhub.
$ docker pull restic/restic

Installing using Source

  • First, you need to install Go programming language to setup Restic from the source. You can visit the official Golang website for the instructions to install Go.
  • Next, execute the commands below to install Restic.
$ git clone https://github.com/restic/restic
$ cd restic
$ go run build.go
  • By specifying target OS in the command, you may quickly compile Restic for all supported platforms. Here are a few examples.
$ go run build.go --goos windows --goarch amd64
$ go run build.go --goos freebsd --goarch 386
$ go run build.go --goos linux --goarch arm --goarm 6

Restic Configuration

As we have already mentioned above that Restic is based on snapshots and repositories for backup. Let’s take a look at how to set up a repository, take a snapshot, and then restore the backup.

Create Repository

  • Run the following command to initialize the repository. You also need to set a password for the repository.
$ restic init --repo /tmp/

Backup data to a local directory

  • In the first step, we have created a repository to store the data. Now, we will add data to the repository for backup. Execute the following command.
$ restic --repo /tmp/backup backup ~/work

Restore the Backup

  • The restore command restores files and directories. The files are not restored to their original location while using Restic. You must choose a target location for the files to be restored by Restic.
$ restic restore 47a15bab -r /tmp/backup --target /tmp/backup/restore
  • However, you can restore the latest snapshot without specifying the snapshot ID. You need to add the latest parameter in the command as below.
$ restic restore latest -r /tmp/backup --target /tmp/backup/restore

Working with Snapshots

In this section, we’ll look at some of the Snapshots’ features.

  • Run the following command to list down the snaphosts.
$ restic snapshots -r /tmp/backup
  • You can compare two snapshots with the following command.
$ restic diff -r /tmp/backup First_Snapshot_ID Second_Snapshot_ID
  • You may need to delete an old backup to free up storage space. To remove a snapshot, run the command below.
$ restic -r /srv/restic-repo forget bdbd3439

Conclusion

In this article, we covered the Restic open source backup software. We also discussed several installation techniques, as well as how to create a backup and restore it. There are many other forms of data backup storage, and we’ve just addressed one in this article. The remaining backend storage types will be covered in future publications. We hope that this tutorial will serve as a starting point for you to use Restic to take and restore backups.

Finally, containerize.com is in a consistent process of writing blog posts on further latest open source products. Therefore, stay in touch with this Backup Software category for the latest updates.