How to install restic backup tool on ubuntu/debian linux

How to Install Restic backup tool on Ubuntu/Debian Linux

In this article, we will see how to install restic backup tool on Ubuntu/Debian based linux systems. Restic is a free and open source, cross platform backup tool designed to create and manage backups efficiently and securely on multiple types of storage backends including Amazon, Google and Microsoft cloud storages. It can take backup of files, directories and even entire filesystems and store it in different cloud storage services. Similarly, it can also restore data from those cloud storages to almost anywhere you would like without much trouble.

It employs features like Data Integrity and Data deduplication which ensures only unique data blocks are stored, hence saves both disk space and bandwidth. Restic uses AES-256 encryption algorithm to encrypt all your backups, hence preventing anonymous to access your data without correct authentication. Restic also allows you to take incremental backups instead of taking entire backup everytime, hence making process lot efficient and faster. It works hassle free on almost all famous platforms such as Linux, Mac, Windows and even on FreeBSD. Here we will see steps to install and use Restic on Ubuntu/Debian based Linux Systems.

Sponsored

 

How to install restic backup tool on ubuntu/debian linux

How to Install Restic backup tool on Ubuntu/Debian Linux

Also Read: How to Install Google Cloud AI Python client library to interact with Vertex AI

Step 1: Prerequisites

a) You should have a running Ubuntu/Debian(in our case, we are using Ubuntu 22.04 LTS here) Server.

b) You should have sudo or root access to run privileged commands.

c) You would require wget and bunzip2 utility in case you would like to install the binary package.

d) Minimum hardware requirements:-

  • CPU: Any modern cpu supported in Ubuntu/Debian system would be enough for optimal performance.
  • Memory: Minimum 2GB of RAM required for basic backup and restore operations. Higher memory would be required for larger data size as Restic loads metadata into memory.
  • Hard Disk: Storage would depend of the size of the data to backup but restic binary package takes around 10MB size.

 

Step 2: Update Your Server

It is always recommended to look for latest features and updates before installing any new packages and install them using sudo apt update && sudo apt upgrade command as shown below. This will keep your system stable and secure at all times.

Ubuntu-Server@ubuntu:~$ sudo apt update && sudo apt upgrade

 

See also  Join Canonical in Sydney at Dell Technologies Forum

Step 3: Install Restic

There are multiple ways to install and use restic on ubuntu/debian based linux systems. You can choose any of the below method to install depending on your requirement.

a) Using apt or apt-get

Since restic is available through ubuntu repo, if you are not worried about latest version then you can choose to install directly from repo by using sudo apt install restic command as shown below. This will download and install the package along with all its dependencies.

Ubuntu-Server@ubuntu:~$ sudo apt install restic
[sudo] password for Ubuntu-Server:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
sphinx-rtd-theme-common
The following NEW packages will be installed:
restic
0 upgraded, 1 newly installed, 0 to remove and 77 not upgraded.
Need to get 7,391 kB of archives.
After this operation, 20.3 MB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 restic amd64 0.12.1-2ubuntu0.3 [7,391 kB]
Fetched 7,391 kB in 3s (2,523 kB/s)
Selecting previously unselected package restic.
(Reading database ... 242087 files and directories currently installed.)
Preparing to unpack .../restic_0.12.1-2ubuntu0.3_amd64.deb ...
Unpacking restic (0.12.1-2ubuntu0.3) ...
Setting up restic (0.12.1-2ubuntu0.3) ...
Processing triggers for man-db (2.10.2-1) ...

b) Using binary package

If you are looking for latest version then I would recommend you to visit GitHub and download the latest stable version using wget utility. Below wget command would download and save the package in current working directory as restic.bz2

Ubuntu-Server@ubuntu:~$ wget -O restic.bz2 -q https://github.com/restic/restic/releases/download/v0.17.3/restic_0.17.3_linux_amd64.bz2

Once it is successfully downloaded, you have to extract the package by using bunzip2 restic.bz2 command as shown below.

Ubuntu-Server@ubuntu:~$ bunzip2 restic.bz2

Next you have to provide execute permission to restic utility by using chmod +x restic command.

Ubuntu-Server@ubuntu:~$ chmod +x restic

To make restic utility available across system, move it to some globally recognized path such as /usr/local/bin by using sudo mv restic /usr/local/bin command as shown below.

Ubuntu-Server@ubuntu:~$ sudo mv restic /usr/local/bin/

 

Step 4: Check Version

After successful installation, check installed version by using restic version command as shown below.

Sponsored
Ubuntu-Server@ubuntu:~$ restic version
restic 0.17.3 compiled with go1.23.3 on linux/amd64

 

Step 5: Initialize a Repo

Before starting to take backup, we have create a restic repo where all backup snapshots can be taken. To do this, let’s create a directory called backup under user’s home directory using mkdir /home/Ubuntu-Server/backup command as shown below.

See also  How can the financial services sector tackle cloud concentration risk?
Ubuntu-Server@ubuntu:~$ mkdir /home/Ubuntu-Server/backup

Once directory is created, let’s initialized to create a restic repo using restic init --repo /home/Ubuntu-Server/backup command as shown below. It would prompt you to set repository password which will be used to encrypt and access the repository. Then confirm the same password again to finally create restic repository.

Ubuntu-Server@ubuntu:~$ restic init --repo /home/Ubuntu-Server/backup/
enter password for new repository:
enter password again:
created restic repository caa6a00c7b at /home/Ubuntu-Server/backup/

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.

If you switch to backup directory and check the contents you should see something like below.

Ubuntu-Server@ubuntu:~$ cd /home/Ubuntu-Server/backup/
Ubuntu-Server@ubuntu:~/backup$ ls
config data index keys locks snapshots

Let’s understand more about above file and directories created:-

  • config: It is a non readable file that contains repository configuration details
  • data : It is a directory to store encrypted data blocks of your backups
  • index: It is a directory which stores indices for efficient lookups
  • keys: It is a directory which stores encrypted key data

 

Step 6: Backup data

Now that repo is initialized and ready to store backup snapshots, let’s take a backup of data directory available in /home/Ubuntu-Server location using restic -r /home/Ubuntu-Server/backup/ backup /home/Ubuntu-Server/data/ command as shown below. This command would create backup of directory /home/Ubuntu-Server/data and store it in /home/Ubuntu-Server/backup repo.

Ubuntu-Server@ubuntu:~$ restic -r /home/Ubuntu-Server/backup/ backup /home/Ubuntu-Server/data/
enter password for repository:
repository caa6a00c opened (version 2, compression level auto)
created new cache in /home/Ubuntu-Server/.cache/restic
no parent snapshot found, will read all files
[0:00] 0 index files loaded

Files: 3 new, 0 changed, 0 unmodified
Dirs: 3 new, 0 changed, 0 unmodified
Added to the repository: 46.017 MiB (46.019 MiB stored)

processed 3 files, 46.013 MiB in 0:05
snapshot cc227aad saved

 

Step 7: List all snapshots

To list all snapshots stored in restic repo /home/Ubuntu-Server/backup, use restic -r /home/Ubuntu-Server/backup command as shown below. This would prompt you to enter repo password to decrypt and show snapshots data.

Ubuntu-Server@ubuntu:~$ restic -r /home/Ubuntu-Server/backup/ snapshots
enter password for repository:
repository caa6a00c opened (version 2, compression level auto)
ID        Time                 Host      Tags     Paths                  Size
----------------------------------------------------------------------------------------
cc227aad  2024-11-22 11:08:58  ubuntu            /home/Ubuntu-Server/data  46.013 MiB
----------------------------------------------------------------------------------------
1 snapshots

 

Step 8: Restore data from snapshot

You can also restore data from backup taken. For that you have to specify a target directory to restore the data. For example, if we have to restore data from /home/Ubuntu-Server/backup into the target directory /home/Ubuntu-Server/data directory then we have to use restic -r /home/Ubuntu-Server/backup restore latest --target /home/Ubuntu-Server/data command as shown below.

Ubuntu-Server@ubuntu:~$ restic -r /home/Ubuntu-Server/backup restore latest --target /home/Ubuntu-Server/data
enter password for repository:
repository caa6a00c opened (version 2, compression level auto)
[0:00] 100.00% 1 / 1 index files loaded
restoring snapshot cc227aad of [/home/Ubuntu-Server/data] at 2024-11-22 11:08:58.356834662 +0530 IST by Ubuntu-Server@ubuntu to /home/Ubuntu-Server/data
Summary: Restored 6 files/dirs (46.013 MiB) in 0:01

 

See also  Ubuntu Weekly Newsletter Issue 728

Step 9: Delete a snapshot

If you would like to delete a backup snapshot from restic repo then you can do that using snapshot id. To get snapshot id, you can list all snapshots stored in a repo as explained earlier and then take the snapshot id to delete that particular snapshot. For example, here we are deleting snapshot with id cc227aad using restic -r /home/Ubuntu-Server/backup forget cc227aad command as shown below.

Ubuntu-Server@ubuntu:~$ restic -r /home/Ubuntu-Server/backup forget cc227aad
enter password for repository:
repository caa6a00c opened (version 2, compression level auto)
[0:00] 100.00% 1 / 1 files deleted

 

Step 10: Uninstall Restic

Once you are done using restic, you can choose to uninstall it from your system using any of the below methods depending on how you installed it.

a) Using apt or apt-get

If you installed restic from default ubuntu repo then to uninstall run sudo apt remove restic command as shown below. If you also want to remove all dependencies installed with restic package which are not required by system anymore then use --auto-remove option with below command.

Ubuntu-Server@ubuntu:~$ sudo apt remove restic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
restic
0 upgraded, 0 newly installed, 1 to remove and 77 not upgraded.
After this operation, 20.3 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 242219 files and directories currently installed.)
Removing restic (0.12.1-2ubuntu0.3) ...
Processing triggers for man-db (2.10.2-1) ...

If you are looking to remove restic package along with all its associated files and configuration then instead of removing, you can use sudo apt purge restic command to get rid of all the left over files and configurations along with the main package. You can also use --auto-remove option with below command to get rid of all the dependencies installed with restic which are not required by system anymore.

Ubuntu-Server@ubuntu:~$ sudo apt purge restic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
restic*
0 upgraded, 0 newly installed, 1 to remove and 64 not upgraded.
After this operation, 20.3 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 242221 files and directories currently installed.)
Removing restic (0.12.1-2ubuntu0.3) ...
Processing triggers for man-db (2.10.2-1) ...

b) Remove binary tool

If you installed the binary tool then to remove the package, you just have to remove binary package using sudo rm -rf /usr/local/bin/restic command as shown below.

Ubuntu-Server@ubuntu:~$ sudo rm -rf /usr/local/bin/restic
[sudo] password for Ubuntu-Server:


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply