Restic is a modern backup program that can back up your files
Up until a few years ago, I mostly used interface-driven backup applications. In some cases, these would spare me from reading a manual, or opening the terminal. However, even I have come to realize the value of a simple, terminal driven application - that usually has fewer bugs, is much faster and can be automated (scripted) easily.
restic is an example of that; We’ll use that below.
Here’s how-to create an encrypted backup on the command line:
Install the backup application:
guix package -i restic
Find out where where your drive is mounted:
$ ls /media/your_username
# example: ls /media/franz
# 68bcdc8a-3661-4c0a-81ce-4d5077a1367f/
I’d suggest to create a sub-folder for the backup. For ex.
mkdir /media/your_username/some-long-uuid-string/backup
# example: mkdir /media/franz/68bcdc8a-3661-4c0a-81ce-4d5077a1367f/backup
Now you can configure your backup. This will prompt you for an encryption password.
restic init --repo /media/your_username/some-long-uuid-string/backup
# example: restic init --repo /media/franz/68bcdc8a-3661-4c0a-81ce-4d5077a1367f/backup
Next, create a bash file, to easily run the backup, whenever the drive is attached. For this, you can use your preferred text-editor; here’s how-to open nano
:
nano ~/backup.sh
If you simply want to backup all your files, with a few exclusions (I have quite a few), write something like this into the backup.sh
(make sure to use your username and backup location path!):
restic -r /media/franz/68bcdc8a-3661-4c0a-81ce-4d5077a1367f/backup --verbose backup /home/franz \
--exclude /home/franz/Android \
--exclude /home/franz/.android \
--exclude /home/franz/.npm \
--exclude /home/franz/.NPM_GLOBAL \
--exclude /home/franz/.npm-packages \
--exclude /home/franz/.pm2 \
--exclude /home/franz/.var \
--exclude /home/franz/.cache \
--exclude /home/franz/.cargo \
--exclude /home/franz/.gradle \
--exclude /home/franz/.local/share/flatpak \
--exclude /home/franz/.local/share/Trash \
--exclude /home/franz/.java \
--exclude /home/franz/.kde \
--exclude /home/franz/.dbus \
--exclude /home/franz/.recoll \
--exclude /home/franz/.recollweb
Write the file with STRG + O
. Confirm the file name. Close with STRG + X
.
Now simply run the file, whenever you want to backup (assuming the drive is attached):
bash backup.sh
You will be prompted for your backup password.
If you’ve made it this far, here’s some more links to checkout:
A couple of notes:
restic -r ./backup forget --keep-last 14 --prune
restic
does not check if there’s enough disk space, to complete the backupI haven’t automated this yet, but once I do, I’ll make sure to share it here.
PantherX & (unofficial) GNU Guix Wiki.
Last update: 2024-04-21 10:28:03 +0000 | Apache-2.0
Inspired by the excellent Arch Linux Wiki