Skip to content

Instantly share code, notes, and snippets.

@henri
Last active May 27, 2025 22:50
Show Gist options
  • Save henri/a2ad48bf2dcb148d4ad1e46af9ef742d to your computer and use it in GitHub Desktop.
Save henri/a2ad48bf2dcb148d4ad1e46af9ef742d to your computer and use it in GitHub Desktop.
restic cheatsheet (specific to fish shell)
# update to latest version of restic
sudo restic self-update
# initilise restic backup repository + generate an initial key
restic init -r <repository-directory>
# configure enviroemnt varables (fish) / alter as needed
set -x RESTIC_REPOSITORY /path/to/repository
set -x RESTIC_PASSWORD_FILE /path/to/.restic_password
set -x RESTIC_PASSWORD my_AmZiNiNg_password
# run a backup to the repository
restic backup <backup-source-file-or-directory> --exclude-file=/path/to/.restic_exclude
# dry run (pretend backup) with verbosity
restic backup <backup-source-file-or-directory> --exclude-file=/path/to/.restic_exclude --dry-run --verbose
# show snapshots
restic snapshots
# show just top level items in latest snapshot
restic ls latest /
# show all files from top leve in latest latest snapshot
restic ls (restic snapshots --json | jq 'sort_by(.time) | .[-1]' | grep '"id": ' | tr -d , | tr -d \" | awk '{print $2}') | grep -E "^/"
# another approach is to tag a snapshot and then list it via that tag...
# prune snapshot data
restic prune
# check the repository
restic check
# delete all snapshots older than 2 hours
restic forget --keep-within 2h --prune
# delete all snapthots older than 2 days
restic forget --keep-within 2d --prune
# delete all snapshots older than 2 months old
restic forget --keep-within 2h --prune
# delete all snapthots older than 2 years old
restic forget --keep-within 2y --prune
# exclude top level direcotry "dont_backup"
dont_backup/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment