{"id":175832,"date":"2021-02-11T16:00:02","date_gmt":"2021-02-11T13:00:02","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/"},"modified":"2021-02-11T16:00:02","modified_gmt":"2021-02-11T13:00:02","slug":"how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/","title":{"rendered":"#How to Use the restic Backup Program on Linux \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2e5fc309b35\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2e5fc309b35\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#The_Value_of_Backups\" >The Value of Backups<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Where_to_Back_up_to\" >Where to Back up to<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Installing_restic\" >Installing restic<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Setting_up_restic\" >Setting up restic<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Creating_a_Backup\" >Creating a Backup<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Working_With_Snapshots\" >Working With Snapshots<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Restoring_Data\" >Restoring Data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-restic-backup-program-on-linux-cloudsavvy-it\/#Make_Backups_Sleep_Easy\" >Make Backups, Sleep Easy<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Use the restic Backup Program on Linux \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9564\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/93a96cf9654be27e78373df794afebf3\/p\/uploads\/2021\/02\/78c23137.png\" alt=\"\" width=\"700\" height=\"300\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Safeguard your precious files and irreplaceable photos with the restic backup program. It\u2019s fast, encrypted, and you can use it straight from the Linux command line.\u00a0Here\u2019s how to set it up.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"The_Value_of_Backups\"><\/span>The Value of Backups<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>All hardware has a finite life. Mechanical\u00a0<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Hard_disk_drive\">hard disk drives<\/a> (HDDs) and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Solid-state_drive\">solid-state drives<\/a> (SSDs) don\u2019t last forever. Accidents h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>en, too. Laptops can be lost, stolen, or dropped down the stairs.<\/p>\n<p>It used to be said that the value of an effective backup system only becomes clear once you\u2019ve lost data. When\u00a0failures or losses occur, you need to have a fast and easy way to get your files and information back. If an organization loses data, the implications are severe. It could even jeopardize business continuity.\u00a0Even in a domestic setting, data loss can be a painful experience. Backups are the only sensible safeguards.<\/p>\n<p>And on top of everything else, the\u00a0accidental\u2014or malicious\u2014loss of personally identifiable data is considered a breach under some data protection legislation, such as the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/eur-lex.europa.eu\/legal-content\/EN\/TXT\/HTML\/?uri=CELEX:32016R0679&amp;qid=1600605964569&amp;from=EN\">General Data Protection Regulation<\/a> (GDPR).<\/p>\n<p>There\u2019s a couple of considerations to observe when you choose backup software. Where do you want your backups to be kept? On a removable drive, on another machine across your <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Local_area_network\">local area network<\/a> (LAN), or in cloud storage? Obviously, you need to use a backup program that can write and restore from the data storage you wish to use.<\/p>\n<p>Backups should be encrypted, especially if they are going to be stored in off-premise locations or in the cloud. If they are encrypted, they cannot be read and restored by unauthorized people.<\/p>\n<p>The program should be fast. You don\u2019t want to wait all day for a backup or restore to complete. Some programs store a base backup image and then store the differences between the base image and the source machine for each subsequent backup. This speeds up the backup process considerably. It also uses less space for your backups.<\/p>\n<p>restic does all of this. It is free, open-source, licensed under the 2<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/opensource.org\/licenses\/BSD-2-Clause\">-Clause BSD License<\/a>, and under active development. The source code is on <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/restic\/restic\">GitHub<\/a>.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Where_to_Back_up_to\"><\/span>Where to Back up to<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this article, we\u2019re going to be storing our backups on another computer across our network.\u00a0That\u2019s great, because that provides fast file transfers, and it\u2019s easy to back up and restore from.\u00a0In a real-world scenario, you really need to back up to another off-site location as well. If your live systems and backups are at the same location and a disaster occurs at that location\u2014a fire, a theft, or a flood\u2014your goose is going to be cooked unless you have an off-premise backup.<\/p>\n<p>Unsurprisingly, restic can back up to an external drive that can be taken away from the premises, and\u2014even better\u2014it can back up straight to cloud storage.<\/p>\n<p>Out of the box, restic <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/restic.readthedocs.io\/en\/latest\/030_preparing_a_new_repo.html#\">can back up to<\/a>:<\/p>\n<ul>\n<li>A local directory or local removable drive.<\/li>\n<li>A networked computer via\u00a0<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/SSH_File_Transfer_Protocol\">SSH File Transfer Protocol<\/a> (SFTP). This, of course, requires <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/SSH_(Secure_Shell)\">Secure Shell<\/a> (SSH).<\/li>\n<li>HTTP REST server.<\/li>\n<li>AWS S3.<\/li>\n<li>OpenStack Swift.<\/li>\n<li>BackBlaze B2.<\/li>\n<li>Microsoft Azure Blob Storage.<\/li>\n<li>Google Cloud Storage.<\/li>\n<\/ul>\n<p>If you need to back up to a data destination that isn\u2019t in that list, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/restic.readthedocs.io\/en\/stable\/030_preparing_a_new_repo.html?highlight=sftp#other-services-via-rclone\">you can combine the power<\/a> of rclone with restic and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/rclone.org\/docs\/\">back up to any of the 40 or so<\/a>\u00a0destinations that rclone supports.<\/p>\n<p>SFTP network backups require SSH to be installed and configured on the backup server. This is the machine that the backups will be stored on.\u00a0If you\u00a0set up SSH keys on the backup server and the machine you\u2019re going to back up, you won\u2019t be prompted for the SSH password every time you run a backup.<\/p>\n<p>One way to automate your backups is to create <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/439736\/how-to-create-aliases-and-shell-functions-on-linux\/\">short scripts or shell functions<\/a> and use cron to run them at specified times.\u00a0Using SSH keys will allow you to avoid the problem of providing a password for unattended backups.<\/p>\n<p><strong>RELATED:<\/strong> <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/424510\/how-to-create-and-install-ssh-keys-from-the-linux-shell\/\"><strong><em>How to Create and Install SSH Keys From the Linux Shell<\/em><\/strong><\/a><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Installing_restic\"><\/span>Installing restic<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The restic application is in the repositories of the main Linux distributions, so installing it is a simple one-liner using the package manager of each distribution.<\/p>\n<p>To install restic on Ubuntu, type:<\/p>\n<pre>sudo apt install restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9423\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/c4a5318327f46a6f34c926cbd67c37f9\/p\/uploads\/2021\/02\/4a47a0db.png\" alt=\"\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The command to use on Fedora is:<\/p>\n<pre>sudo dnf install restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9425\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/683de4ec3635918930a7caf23a1d45a4\/p\/uploads\/2021\/02\/a8911d2f.png\" alt=\"\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>On Manjaro we use <code>pacman<\/code>:<\/p>\n<pre>sudo pacman -Sy restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9426\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/62cbb6135231c4280ddc913fa758965a\/p\/uploads\/2021\/02\/db67a724.png\" alt=\"\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Setting_up_restic\"><\/span>Setting up restic<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Make sure you have SSH set up on the backup server machine, and that you can make a remote connection to it from the machine you\u2019re going to back up. That\u2019s the client machine. In our test network, the client is called \u201cubuntu-20-10,\u201d and the server is called \u201cbackup-box.\u201d<\/p>\n<p>In restic\u2019s terminology, backups are stored as snapshots in a repository. Each backup creates a new snapshot. We need to create a place for the repository on the server.<\/p>\n<p>We need to create a directory on the backup server to hold the repository. Historically, services that were served up by a server were located in the \u201c\/srv\u201d directory. So we\u2019ll place our repository there.<\/p>\n<p>On the backup server, issue this command. You can name the repository directory whatever you like. We\u2019re using the name \u201crestic\u201d for the sake of simplicity.<\/p>\n<pre>sudo mkdir \/srv\/restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9427\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/05c0795a51522ce21148b1b94ef106fe\/p\/uploads\/2021\/02\/fb5c81ed.png\" alt=\"\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We need to make sure that this directory is accessible to the person who will be handling backups. If it were multiple people, it would make sense to create a user group and give the group access to the directory.<\/p>\n<pre>sudo chown dave:dave \/srv\/restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9429\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/3931cf78ad40f30a4db297c9eabd3678\/p\/uploads\/2021\/02\/10fb15c7.png\" alt=\"\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Let\u2019s check the settings on the directory:<\/p>\n<pre>ls -hl \/srv<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9430\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/497cec59eb63501be69b1fdf4c7b5bd3\/p\/uploads\/2021\/02\/09dd8c26.png\" alt=\"\" width=\"646\" height=\"122\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Now we can move over to the client machine and create the repository on the server from there. Substitute the name of your user, the name of the backup server, and the name of the repository directory to match your choices. You can use the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/IP_address\">IP address<\/a> of the backup server if you prefer.<\/p>\n<p>We\u2019re using the <code>-r<\/code> (repository) option to specify the path to the repository that we\u2019re going to create. The restic <code>init<\/code>command initializes the repository.<\/p>\n<pre>restic -r sftp:dave@backup-box.local:\/srv\/restic init<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9431\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/a77901db196f93a0691ec140c04d1060\/p\/uploads\/2021\/02\/8266e4bf.png\" alt=\"\" width=\"646\" height=\"77\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You\u2019ll be asked for the password for the user account on the backup server. If you\u2019ve set up SSH keys between the server and the client, you won\u2019t need to perform this step.<\/p>\n<p>You\u2019ll also be asked for the repository password, and then you\u2019ll be asked to confirm it. This password must be used to interact with the repository in the future. Don\u2019t lose it! You won\u2019t be able to back up or restore the data if you lose the password.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9432\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/2c72a7ef5f167d674eca064489f763b2\/p\/uploads\/2021\/02\/f19c9085.png\" alt=\"\" width=\"646\" height=\"247\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>It only takes a moment for the repository to be created and initialized.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Creating_a_Backup\"><\/span>Creating a Backup<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Creating a backup is very simple. We use the <code>backup<\/code> command with restic, tell it what we want to back up, and which repository to send the backup to.<\/p>\n<pre>restic backup Documents\/kernel\/ -r sftp:dave@backup-box.local:\/srv\/restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9433\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/6f61eb3e04615c869befcb92f49f8833\/p\/uploads\/2021\/02\/9eb9cd58.png\" alt=\"\" width=\"647\" height=\"77\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You need to provide the user\u2019s password and the password for the repository. While the backup is running, the names of the files being copied are displayed, along with statistics telling you how many files are going to be copied in total, how many have been copied so far, and what percentage of the backup is complete. The snapshots are encrypted using the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Advanced_Encryption_Standard\">advanced encryption standard<\/a> AES-256.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9435\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/3f5cd13aeca0e05a79ebf2c66e9e8e11\/p\/uploads\/2021\/02\/602e8f04.png\" alt=\"\" width=\"646\" height=\"212\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Because this was the first backup to this repository, all the files that were backed up were new. We did say that restic was fast\u2014over 70,000 files were backed up in 23 seconds. That\u2019s all of the source code for the Linux kernel.<\/p>\n<p>On another test machine, I backed up over 350,000 files amounting to over 170 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Byte#Units_based_on_powers_of_2\">GiB<\/a> in an hour and a half.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9436\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/be18f88cfbad1fca85e8ff41c917ebd1\/p\/uploads\/2021\/02\/7afbb160.png\" alt=\"\" width=\"646\" height=\"307\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>I created a new file on the client in the source directory and ran another backup. The command is the same as before.<\/p>\n<pre>restic backup Documents\/kernel\/ -r sftp:dave@backup-box.local:\/srv\/restic<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9437\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/e12163cd90c7e932310a73390177fcfe\/p\/uploads\/2021\/02\/586e508f.png\" alt=\"\" width=\"646\" height=\"292\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The source directory tree was scanned for changes, the new file was detected, and it was backed up. That second tiny backup took three seconds to complete, including scanning the other files for changes.<\/p>\n<p>Let\u2019s take a look at the two snapshots we have in the repository. The restic command for this is\u00a0<code>snapshots<\/code>.<\/p>\n<pre>restic -r sftp:dave@backup-box.local:\/srv\/restic snapshots<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9438\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/f2a9b66b934e15653486ee1fe333cc5d\/p\/uploads\/2021\/02\/59b2900a.png\" alt=\"\" width=\"646\" height=\"337\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Each snapshot has been given a hexadecimal identifier as a unique ID. The date and time when each snapshot was created are displayed. The name of the computer that the backup was made from and the path to the data that was backed up is also shown.<\/p>\n<p>I then created a second new file and created another backup. Again, the command line is the same as before.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9439\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/c1c583e0f49efd0c964c26e10a445e10\/p\/uploads\/2021\/02\/9eb60bc8.png\" alt=\"\" width=\"646\" height=\"262\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Just like with our earlier top-up backup, this tiny update took three seconds to complete.<\/p>\n<p>By now, you\u2019re probably tired of entering the repository password. We can address that before we use the <code>snapshots<\/code> command to look at our collection of three snapshots. Open an editor and type the repository password in it, then hit \u201cEnter\u201d to start a new line. Save the file as \u201c.rest_pass\u201d in your home directory.<\/p>\n<p>To make sure that no one else can see the password,\u00a0<a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/chmod.1.html\">change the access mode bits of the file<\/a> using <code>chmod<\/code> :<\/p>\n<pre>chmod 600 .rest_pass<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9440\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/2d7e22f5bf011fcce75735062bced02c\/p\/uploads\/2021\/02\/c00b5755.png\" alt=\"\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This means that no one but you can access the file.<\/p>\n<p>Now we can pass this to the rest command line using the <code>-p<\/code> (password file) option. If you\u2019ve also set up SSH keys between the client and the server, you won\u2019t have to enter the user account password either. You can easily automate your backups with <code>cron<\/code> once the human interaction has been removed from the process.<\/p>\n<pre>restic snapshots -r sftp:dave@backup-box.local:\/srv\/restic -p .rest_pass<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9442 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/6fcfa107310151faa6e0a725f4f86555\/p\/uploads\/2021\/02\/7b6fbd4c.png\" alt=\"\" width=\"646\" height=\"352\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We\u2019re no longer asked for the repository password, which is great. We don\u2019t need to remember it and we can\u2019t mistype it.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Working_With_Snapshots\"><\/span>Working With Snapshots<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The restic <code>diff<\/code> command lets you see the differences between any two snapshots. Use the unique IDs of the two snapshots you want to compare. You can see the snapshot IDs when you use the restic <code>snapshot<\/code> command.<\/p>\n<pre>restic diff -r sftp:dave@backup-box.local:\/srv\/restic -p .rest_pass 8f98cd29 8700e4bf<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9444 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/4e8ff2def52f9c780f21f78c719bdee1\/p\/uploads\/2021\/02\/d642f8c3.png\" alt=\"\" width=\"646\" height=\"337\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The differences between the snapshots are shown as columns of statistics.<\/p>\n<p>The restic <code>check<\/code> command performs a verification test against all the snapshots in the repository.<\/p>\n<pre>restic check -r sftp:dave@backup-box.local:\/srv\/restic -p .rest_pass<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9447\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/349da47d47f58f428ef9c343798940c4\/p\/uploads\/2021\/02\/1e412544.png\" alt=\"\" width=\"646\" height=\"262\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To delete a snapshot, you must tell restic to <code>forget<\/code> it and to <code>prune<\/code> it. You must use the snapshot\u2019s unique ID to identify which snapshot to delete.<\/p>\n<pre>restic forget --prune -r sftp:dave@backup-box.local:\/srv\/restic -p .rest_pass e506e089<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9448\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/5d27d5e389bcdf785df1e9be20338942\/p\/uploads\/2021\/02\/c9baca3c.png\" alt=\"\" width=\"646\" height=\"452\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Restoring_Data\"><\/span>Restoring Data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When the time comes to restore data from your backups, it\u2019s as easy as it was to create the backup. You need to specify which snapshot you\u2019re going to restore. You can use a snapshot\u2019s unique ID, or you can use the <code>latest<\/code> label to use the newest snapshot in the repository.<\/p>\n<p>You also need to provide a directory for the restored data to be copied to using the <code>target<\/code>\u00a0option.<\/p>\n<pre>restic restore latest --target ~\/restored-data -r sftp:dave@backup-box.local:\/srv\/restic -p .rest_pass<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9451\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/6a11eab6c3038be1aae7531db98d1d03\/p\/uploads\/2021\/02\/78c39f45.png\" alt=\"\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Restoring is as speedy as backing up. Checking in the target directory, we can see that the directory tree and files have been restored for us.<\/p>\n<pre>ls<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9452\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/5b0118ba37f62620afeb71ebebbaf7a5\/p\/uploads\/2021\/02\/079f4fb5.png\" alt=\"\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Make_Backups_Sleep_Easy\"><\/span>Make Backups, Sleep Easy<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Data loss is a serious problem. A robust backup solution means that you have one less thing to worry about. With restic, you can automate your backups to local and cloud repositories and sleep easy.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/9418\/how-to-use-the-restic-backup-program-on-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Use the restic Backup Program on Linux \u2013 CloudSavvy IT&#8221; Safeguard your precious files and irreplaceable photos with the restic backup program. It\u2019s fast, encrypted, and you can use it straight from the Linux command line.\u00a0Here\u2019s how to set it up. The Value of Backups All hardware has a finite life. Mechanical\u00a0hard disk&#8230;<\/p>\n","protected":false},"author":1,"featured_media":175833,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/93a96cf9654be27e78373df794afebf3\/p\/uploads\/2021\/02\/78c23137.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-175832","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/175832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=175832"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/175832\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/175833"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=175832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=175832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=175832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}