Last active
January 27, 2024 13:14
-
-
Save abraithwaite/50f933e70cc0744877c7dcd8d6139c4b to your computer and use it in GitHub Desktop.
Automated Restic Backups with CPU+Memory throttling, inspired by: https://fedoramagazine.org/automate-backups-with-restic-and-systemd/
This file contains 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
B2_ACCOUNT_ID=XXXXXXXXXXXXXXXXXXXXXXXXX | |
B2_ACCOUNT_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
RESTIC_REPOSITORY=b2:XXXXXXXXXXXXXXXXXX:/ | |
RESTIC_PASSWORD=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
BACKUP_PATHS="/home/naomi.nagata" | |
BACKUP_EXCLUDES="--exclude-file /home/rupert/.restic_excludes --exclude-if-present .exclude_from_backup" | |
RETENTION_DAYS=7 | |
RETENTION_WEEKS=4 | |
RETENTION_MONTHS=6 | |
RETENTION_YEARS=3 |
This file contains 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
[Unit] | |
Description=Restic backup service | |
[Service] | |
Type=oneshot | |
Slice=restic.slice | |
ExecStart=/usr/bin/restic backup --verbose --one-file-system --tag systemd.timer $BACKUP_EXCLUDES $BACKUP_PATHS | |
EnvironmentFile=%h/.config/restic-backup.conf | |
# TODO: retention | |
# ExecStartPost=restic forget --verbose --tag systemd.timer --group-by "paths,tags" --keep-daily $RETENTION_DAYS --keep-weekly $RETENTION_WEEKS --keep-monthly $RETENTION_MONTHS --keep-yearly $RETENTION_YEARS |
This file contains 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
[Slice] | |
# 2 CPUs, adjust to preference | |
CPUQuota=200% | |
MemoryHigh=4G |
This file contains 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
[Unit] | |
Description=Backup with restic daily | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
restic.{service,slice,timer}
into~/.config/systemd/user
~/.config/restic-backup.conf
systemctl --user daemon-reload
systemctl --user enable restic.timer