Last active
May 27, 2025 22:50
-
-
Save henri/a2ad48bf2dcb148d4ad1e46af9ef742d to your computer and use it in GitHub Desktop.
restic cheatsheet (specific to fish shell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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