How to manage your backup easily with Restic

Photo by Markus Spiske on Unsplash

Restic is a modern backup program that can back up your files, it works across platforms Linux, BSD, Mac and Windows.

Restic comes with many features that makes it easy to manage your backup such as:

  • Multiple storage types, including self-hosted and online services
  • Easy to setup and deploy, being a single executable that you can run without a server or complex setup
  • Effective, only transferring the parts that actually changed in the files you back up
  • Secure, by careful use of cryptography in every part of the process
  • Verifiable, enabling you to make sure that your files can be restored when needed
  • free — restic is entirely free to use and completely open source

Installing restic on Centos 7

yum install yum-plugin-copr
yum copr enable copart/restic
yum install restic

for other OS or distributions, you can follow the Installation Instructions Page in the manual or download the latest native binary on the GitHub Download Page.

Initializing Backup Repository

A “repository” is the term used by restic to define where your backup will reside. the repository can be stored locally, or on remote server or service. to start using a repository you first initialize it by running the command:

restic init --repo /srv/mybackup

you will be prompted to enter password

Backing-up a directory

after initializing your repository, now you are ready to backup some data. in restic, the content of a directory at a given time is called “snapshot“. to create snapshot of your data you can run

restic -r /srv/mybackup/ --verbose backup /home/samirsomer

you can also utilize the options –include and –exclude with wildcards to fune tune your backup

# exclude all files ending with with ".c" from the home directoryrestic -r /srv/mybackup backup ~/work --exclude="*.c"# exclude all file in list from the home directory
restic -r /srv/mybackup backup ~/work --exclude-file=excludes.txt

Managing snapshots

To list all snapshots in a given repository you can run

restic -r /srv/restic-repo snapshots# to filter the listing by directory path
restic -r /srv/restic-repo snapshots --path="/srv"

if you want to copy you snapshots across repositories, for example from a local repository to a remote one, you can run

# to copy all snapshots
restic -r /srv/mybackup copy --repo2 /tmp/remote-backup
# to copy specific snapshots
restic -r /srv/mybackup copy --repo2 /tmp/remote-backup 410b18a2 4e5d5487 latest

Restoring a Backup

To restore backup you can simply run the below command and pass the snapshot id that you can get from listing the snapshots

restic -r /srv/mybackup/ restore 115b2977 --target /tmp/

This has been a short tutorial on resitc. you can found more details by reading the tool documentation here.

Sudanese | Tech Enthusiast | Internet Mechanic