Quantcast
Channel: Curt Warfield – Fedora Magazine
Viewing all articles
Browse latest Browse all 10

Use restic on Fedora for encrypted backups

$
0
0

Restic is a fast, efficient, free and open source backup application that secures your data with AES-256 encryption. Restic also utilizes deduplication to help conserve backup space. Additionally, Restic is compatible with most major cloud providers. This tutorial walks through installing Restic on Fedora and setting up backups to a cloud storage provider (in this example, BackBlaze B2 Cloud storage).

Installing Restic

Although you can compile restic from source or download it from the release page, there’s a helpful COPR for this utility.  The Fedora Magazine covered this COPR in one of our previous articles. Do note that COPR provided software isn’t supported by Fedora infrastructure or signed by the project.

To enable the COPR for restic, run these commands:

sudo dnf copr enable copart/restic
sudo dnf install restic

Test your installation by typing the following command. If you see the help screen as output, you are ready to go.

restic

Preparing a new repository

Restic refers to your backup as a repository and can make backups to any B2 bucket on your Backblaze account. First, setup the following environment variables using your B2 credentials. These can also be set in any backup script you may create.

export B2_ACCOUNT_ID=<MY_ACCOUNT_ID>
export B2_ACCOUNT_KEY=<MY_SECRET_ACCOUNT_KEY>

Create the repository by initializing it. If the bucket doesn’t already exist,  restic automatically creates it. A prompt appears for you to type a password for the repository. Do not lose this password because your data is irrecoverable without it.

restic -r b2:bucketname:/ init

For example:

$ restic -r b2:g534fbucket:/ init
enter password for new backend:
enter password again:
created restic backend 93702e3c5f at b2:g534fbucket:/

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

Creating backups

Now it’s time to backup some data. Backups are called snapshots. Run the following command and enter the repository password when prompted.

restic -r b2:bucketname:/ backup files_to_backup

For example:

$ restic -r b2:g534fbucket:/ backup Documents/
enter password for repository: 
scan [/home/curt/Documents]
scanned 1 directories, 3 files in 0:00
[0:04] 0B/s 0B / 0B 4 / 4 items 0 errors ETA 0:00 
duration: 0:04, 0.00MiB/s
snapshot d864c465 saved

Restoring from backups

Now that you’ve backed up some files, it’s time to make sure you know how to restore them. To get a list of all of your backup snapshots, use this command:

restic -r b2:bucketname:/ snapshots

For example:

$ restic -r b2:g534fbucket:/ snapshots
enter password for repository: 
ID Date Host Tags Directory
----------------------------------------------------------------------
d864c465 2018-03-27 15:20:42 client /home/curt/Documents

To restore an entire snapshot, run a command like this:

restic -r b2:bucketname:/ restore snapshotID --target restoreDirectory

For example:

$ restic -r b2:g534fbucket:/ restore d864c465 --target ~
enter password for repository: 
restoring <Snapshot d864c465 of [/home/curt/Documents] at 2018-03-27 15:20:42.833131988 -0400 EDT by curt@client> to /home/curt

If the directory still exists on your system, be sure to specify a different location for the restoreDirectory. For example:

restic -r b2:g534fbucket:/ restore d864c465 --target /tmp

To restore an individual file, run a command like this:

$ restic -r b2:g534fbucket:/restore snapshotID --target restoreDirectory --include filename

For example:

$ restic -r b2:g534fbucket:/ restore d864c465 --target /tmp --include file1.txt
enter password for repository: 
restoring <Snapshot d864c465 of [/home/curt/Documents] at 2018-03-27 15:20:42.833131988 -0400 EDT by curt@client> to /tmp

Photo by Samuel Zeller on Unsplash.


Viewing all articles
Browse latest Browse all 10

Trending Articles