Set up restic
2026-02-01
To back up files from a PC you trust to a PC you don't (for example some cloud storage), Restic appears to be ideal.
First: decide where your remote storage should be and how to access it. in my case, a rented Hetzner server i'll access via ssh/sftp. on that server, i'll have some directory like /home/myuser/backups in which we'll create the restic "repositories".
Second: ensure connection works, here SSH setup. The machine that has the data needs to be able to access the storage location. Use SSH keys, not passwords. Once you're able to "ssh myuser@vps.shiny.space" you're good.
Third: initialize restic repo. DO NOT RUN RESTIC COMMANDS ON THE REMOTE / UNTRUSTED SERVER.
you run this on your local, trusted device:
restic -r sftp:myuser@vps.shiny.space:/home/myuser/backups/reponame init
this will ask you for a password. save this password in your password manager, if you lose it you will NOT be able to access your backup. you will also likely want to save that password into a file on your trusted machine, so you can automate the backups.
setup done - the next steps should ideally be a script that you can run automatically, because only automated backups are really worth something. example:
#!/bin/sh
restic -r sftp:myuser@vps.shiny.space:/home/myuser/backups/projects --password-file /path/to/.restic-password backup /path/to/important/data
restic -r sftp:myuser@vps.shiny.space:/home/myuser/backups/projects --password-file /path/to/.restic-password forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 5 --prune