Your Data, Your Problem
If you don’t have possession of it, do you really own it? This is the question I’ve always asked myself when it comes to my data and cloud storage. This is why I have my own personal cloud on my home network. And because I don’t want to lose that data, ever, it requires a robust backup solution. This involves a strategy for not only the Home server, but each individual machine attached to my network. And I don’t know about you, but I always prefer open source tools when I can find them as opposed to spending a bunch of money on software.
What is Restic?
Enter Restic, an open source backup tool that works on multiple platforms like Windows and Linux. In a nutshell if you are familiar with Git, it works in a similar way, but for backups. That is to say it makes incremental backups and only backs up the changes after that first backup. This saves a tremendous amount of time and makes it very easy to automate and mostly forget about.
Getting started – Installation
Restic is a well-known open source backup tool and there are definitely plenty of options for you if you want to find a GUI front end for it, but today I’m going to show you how to use it with just the its native Command Line Interface (CLI).
Install Scoop First
First thing is first, we need to install something called Scoop. This is a cli installation tool that we will use to install the Restic program itself.
To install it, just open a Powershell instance with administrative privileges and run the following:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
Install Restic
Once we have Scoop installed we can install restic. Scoopy makes these very easy. In your Powershell Window run:
scoop install restic
Once Restic has been installed we can move forward with backing up our files!
How to Backup and Restore with Restic
Repository Creation
As mentioned earlier, Restic is sort of like Git. This means it organizes it backups in “Repositories” which group the items you want to backup together so Restic knows details about each backup you make. So the first thing we need to do is create a repository to hold our backup. Open a Powershell or Command Prompt Window and enter the following:
restic init -r \\Path\to\repo
Replace the path with the location on your computer where you want the backup to go.
Restic will then prompt you for a password. It’s very important to remember that password. Its the only way you’ll ever restore.
Creating the Backup
To create a backup we will run a command like this:
restic backup -r $repoPath $folder1 $folder2
In this example replace $repoPath with the path to the repository you just created above.
$folder1 and $folder2 Represet the paths of folders on your computer that you want to back up. For example you could have
restic backup -r D:\Backups\backup1 C:/Programs C:/Documents
This would backup everything in your Programs and Documents folder.
List Snapshots
Snapshots are kind of what they sound. They are pictures of what the backup looked like when it was ran on a certain date/time. This gives you the ability to not just roll back to the latest update but go back further if need be. to list the snapshots run:
restic -r $repoPath snapshots
Again where $repoPath represents the original backup repository location you setup.
Restoring a Backup
Restoring a backup is pretty straightforward and simple. In general the command follows this format:
restic -r $repoPath -t restore latest $targetRestorationPath
Obviously replace $repoPath and $targetRestorationPath with your relevant paths. “latest” is just a tag for the last snapshot but you could replace this with one from the List snapshots command if you wanted to restore a different one.
Conclusion
So that’s really about it. As you can see working with Restic via CLI is really not that hard. Its a robust tool that can save you tons of money and time, and it works well when you use things like batch files or other Powershell scripts in combination with the native Task Scheduler to just automate your backups. In a future post I will walk you through how to do exactly that! Thanks for reading!
0 Comments