Last active
April 6, 2026 14:01
-
-
Save Alistair1231/b95f7c4a0b2b0e8474297b43675088db to your computer and use it in GitHub Desktop.
restic backup script for docker bind mounts
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
| # /etc/systemd/system/restic-backup.service | |
| [Unit] | |
| Description=restic-backup | |
| [Service] | |
| Type=oneshot | |
| ExecStart=/home/al/restic.sh | |
| WorkingDirectory=/home/al |
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
| # /etc/systemd/system/restic-backup.timer | |
| [Unit] | |
| Description=restic-backup | |
| [Timer] | |
| OnBootSec=5m | |
| OnUnitActiveSec=1h | |
| [Install] | |
| WantedBy=timers.target |
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
| # ~/restic.env | |
| export RCLONE_CONFIG=/etc/rclone/rclone.conf | |
| export RESTIC_PASSWORD="secure-password" | |
| export RESTIC_REPOSITORY="sftp:al@10.10.0.222:/mnt/storage/backups/al-game" | |
| export HOME="/home/al" | |
| export SSH_KEY="/home/al/.ssh/id_game" |
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
| # ~/restic.exclude | |
| # various big stuff | |
| /home/al/.local/share/Steam | |
| /home/al/.local/share/flatpak | |
| /home/al/.local/share/Trash | |
| /home/al/.local/share/bottles | |
| /home/al/.local/share/containers | |
| /home/al/winboat | |
| /home/al/Mods | |
| /home/al/Videos | |
| /home/al/Music/Libation | |
| /home/al/Downloads | |
| /home/al/.ftba | |
| /home/al/.vscode | |
| # programming stuff | |
| /home/al/.cargo/registry | |
| /home/al/.cargo/git | |
| /home/al/.gradle/caches | |
| /home/al/.m2/repository | |
| /home/al/.npm/_cacache | |
| /home/al/.ccache | |
| # Cache and log files | |
| /home/al/**/*Cache* | |
| /home/al/**/*cache* | |
| /home/al/.cache | |
| /home/al/.cache/** | |
| /home/al/.local/state | |
| /home/al/.local/state/** | |
| /home/al/.log | |
| /home/al/.log/** | |
| # Flatpak | |
| /home/al/.var/app/moe.launcher.sleepy-launcher/data/sleepy-launcher/ | |
| /home/al/.var/app/*/cache | |
| /home/al/.var/app/*/.cache | |
| /home/al/.var/app/*/tmp | |
| /home/al/.var/app/*/.tmp | |
| /home/al/.var/app/*/log | |
| /home/al/.var/app/*/.local/state |
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
| #!/usr/bin/env bash | |
| # ~/restic.sh | |
| source /home/al/restic.env | |
| echo "========= $(date) =========" | |
| # Unlock repository (in case of stale locks) | |
| /usr/bin/restic -vv unlock \ | |
| -o sftp.args="-i $SSH_KEY" | |
| # Backup | |
| /usr/bin/restic -vv backup $HOME /etc \ | |
| -o sftp.args="-i $SSH_KEY" \ | |
| --exclude-file="$HOME/restic.exclude" | |
| # Forget old snapshots and prune | |
| /usr/bin/restic -vv forget \ | |
| -o sftp.args="-i $SSH_KEY" \ | |
| --retry-lock "5m" \ | |
| --keep-last 24 \ | |
| --keep-daily 7 \ | |
| --keep-weekly 4 \ | |
| --keep-monthly 2 \ | |
| --prune | |
| # Check repository | |
| /usr/bin/restic -vv check \ | |
| -o sftp.args="-i $SSH_KEY" \ | |
| echo "========= END $(date) =========" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment