My backup routine with restic
restic is a backup utility that ensures data integrity, and its main feature is the ability to keep data encrypted in a repository structured much like what we see in Git.
That is, versioning is the rule, and that is its second main feature, besides the encryption already mentioned.
Along with versioning we also get deduplication: in a restic repository, a piece of data is stored only once and is just referenced afterwards.
And finally, repositories also support compression. So, to recap, we have an encrypted, deduplicated, versioned and compressed repository.
Currently, my backup routine is a crontab that runs the following script:
#!/bin/sh repositorio="/backup" #repository path password_file="/armazem/Sync/senha.txt" #file with the password # 'unlock' removes any locks left by a previous restic process restic --password-file=$password_file -r $repositorio unlock # 'prune' removes from the repository any leftover data belonging to snapshots that were already deleted. restic --password-file=$password_file -r $repositorio prune # Here we set the backup retention policy: 7 daily backups, one for each day of the week, two weekly and 1 monthly. restic --password-file=$password_file -r $repositorio forget --keep-daily 7 --keep-weekly 2 --keep-monthly 1 --keep-tag keep --prune # Finally, we back up my home folder (giuliano) restic --exclude-caches --exclude=".cache" --password-file=$password_file -r $repositorio backup /home/giuliano # And here we finish by backing up the /armazem folder, which is on another disk and holds many relevant files. restic --exclude-caches --exclude="backup" --exclude="tv" --exclude="downloads" --exclude="movies" --exclude="local" --password-file=$password_file -r $repositorio backup /armazem
To check the backups, I can run the following command:
restic --password-file=/armazem/Sync/senha.txt -r /armazem/backup snapshots
Which returns the following output:
repository 6359e57a opened (version 2, compression level auto) ID Time Host Tags Paths --------------------------------------------------------------------------- dac71fa4 2024-01-18 04:01:32 ryzen /home/giuliano c46518e1 2024-01-18 04:03:45 ryzen /armazem 81732621 2024-01-19 04:01:13 ryzen /home/giuliano 76412b53 2024-01-19 04:03:29 ryzen /armazem e8754b00 2024-01-20 04:01:16 ryzen /home/giuliano fd999edd 2024-01-20 04:03:53 ryzen /armazem af0037f0 2024-01-21 04:01:24 ryzen /home/giuliano baa4f85b 2024-01-21 04:05:19 ryzen /armazem 95f5eecb 2024-01-22 04:00:41 ryzen /home/giuliano bfa109cb 2024-01-22 04:03:38 ryzen /armazem f342549a 2024-01-23 04:01:24 ryzen /home/giuliano bd7d291b 2024-01-23 04:04:26 ryzen /armazem c0d67f5a 2024-01-24 04:01:33 ryzen /home/giuliano 961f1829 2024-01-24 04:04:14 ryzen /armazem c41d42dd 2024-01-25 04:01:29 ryzen /home/giuliano ad507348 2024-01-25 04:03:10 ryzen /armazem --------------------------------------------------------------------------- 16 snapshots
In case of disaster, just run the following command to restore a backup:
restic --password-file=/armazem/Sync/senha.txt -r /armazem/backup restore b1297a9c --target=/
Here b1297a9c is the snapshot's unique ID and the other parameters are the password file and the repository. The target is the root, because restic stores the folder structure starting from the root, so it usually makes the most sense to restore from there.
This is just a quick demo of what restic can do. It is also worth noting that it has native rclone support, as long as both tools are installed, which opens up countless cloud providers as a "backend".
In addition, restic has a considerable list of GUIs and utilities that make it easier to use, which you can check out here: https://github.com/rubiojr/awesome-restic
The combination of these features makes restic a robust and versatile backup tool, serving home users as well as more demanding business environments. Its extensive support for different cloud backends, along with the possibility of integrating with other tools such as rclone, gives unprecedented flexibility in choosing how and where to store your backups.
I encourage everyone interested to explore its features and to consider restic as a backup solution. Whether you are a tech enthusiast looking for a reliable tool to protect personal data, or a company seeking an efficient and secure backup solution, restic offers a powerful combination of simplicity, flexibility and security.
Be sure to check out the community and the available resources to get the most out of restic. The security of your data is essential, and choosing the right tool is the first step to ensuring that security in an increasingly complex digital world.