Add `restic` config

bladee.bsky.social 44b4c37f ea31445e

verified
+8
dot_config/private_fish/functions/restic-chert.fish.tmpl
···
···
+
function restic-chert --wraps=restic
+
set -x RESTIC_REPOSITORY {{ printf "%s/%s" .restic.chert.baseOpId "restic repository" | quote }}
+
set -x RESTIC_PASSWORD {{ printf "%s/%s" .restic.chert.baseOpId "restic password" | quote }}
+
set -x AWS_ACCESS_KEY_ID {{ printf "%s/%s" .restic.chert.baseOpId "access key id" | quote }}
+
set -x AWS_SECRET_ACCESS_KEY {{ printf "%s/%s" .restic.chert.baseOpId "secret access key" | quote }}
+
+
command op run -- restic $argv
+
end
+8
dot_config/private_fish/functions/restic-pulsar.fish.tmpl
···
···
+
function restic-pulsar --wraps=restic
+
set -x RESTIC_REPOSITORY {{ printf "%s/%s" .restic.pulsar.baseOpId "restic repository" | quote }}
+
set -x RESTIC_PASSWORD {{ printf "%s/%s" .restic.pulsar.baseOpId "restic password" | quote }}
+
set -x AWS_ACCESS_KEY_ID {{ printf "%s/%s" .restic.pulsar.baseOpId "access key id" | quote }}
+
set -x AWS_SECRET_ACCESS_KEY {{ printf "%s/%s" .restic.pulsar.baseOpId "secret access key" | quote }}
+
+
command op run -- restic $argv
+
end
+8
dot_config/private_fish/functions/restic-slate.fish.tmpl
···
···
+
function restic-slate --wraps=restic
+
set -x RESTIC_REPOSITORY {{ printf "%s/%s" .restic.slate.baseOpId "restic repository" | quote }}
+
set -x RESTIC_PASSWORD {{ printf "%s/%s" .restic.slate.baseOpId "restic password" | quote }}
+
set -x AWS_ACCESS_KEY_ID {{ printf "%s/%s" .restic.slate.baseOpId "access key id" | quote }}
+
set -x AWS_SECRET_ACCESS_KEY {{ printf "%s/%s" .restic.slate.baseOpId "secret access key" | quote }}
+
+
command op run -- restic $argv
+
end
+26
dot_config/restic/excludes.conf
···
···
+
$HOME/.1password/
+
$HOME/.android/
+
$HOME/.BitwigStudio/
+
$HOME/.cache/
+
$HOME/.gradle/
+
$HOME/.java/
+
$HOME/.local/share/
+
$HOME/.local/state/
+
$HOME/.jdks/
+
$HOME/.pki/
+
$HOME/.skiko/
+
$HOME/.vscode/
+
+
$HOME/Downloads/
+
$HOME/Dropbox/
+
$HOME/Google Drive/
+
$HOME/Music/
+
$HOME/Videos/
+
+
$HOME/.var/app/**/cache/
+
$HOME/.var/app/**/.cache/
+
$HOME/.var/app/**/data/
+
$HOME/.var/app/**/.local/share/
+
+
**/mkosi.cache/
+
**/mkosi.output/
+15
dot_config/restic/private_backup.conf.tmpl
···
···
+
RESTIC_REPOSITORY={{ onepasswordRead (printf "%s/%s" .restic.slate.baseOpId "restic repository") | quote }}
+
RESTIC_PASSWORD={{ onepasswordRead (printf "%s/%s" .restic.slate.baseOpId "restic password") | quote }}
+
+
AWS_ACCESS_KEY_ID={{ onepasswordRead (printf "%s/%s" .restic.slate.baseOpId "access key id")| quote }}
+
AWS_SECRET_ACCESS_KEY={{ onepasswordRead (printf "%s/%s" .restic.slate.baseOpId "secret access key") | quote }}
+
+
BACKUP_PATHS={{ .chezmoi.homeDir | quote }}
+
BACKUP_TAGS=Automatic
+
+
UPLOAD_LIMIT=5000
+
+
RETENTION_DAYS=7
+
RETENTION_WEEKS=4
+
RETENTION_MONTHS=12
+
RETENTION_YEARS=unlimited
+16
dot_config/systemd/user/restic-backup.service.tmpl
···
···
+
[Unit]
+
Description=Backup home directory
+
After=network-online.target
+
Wants=network-online.target
+
+
[Service]
+
Type=oneshot
+
Environment=XDG_CACHE_HOME=%T
+
EnvironmentFile=%h/.config/restic/backup.conf
+
{{ $resticPath := lookPath "restic" -}}
+
ExecStart={{ $resticPath }} backup --verbose --limit-upload "$UPLOAD_LIMIT" --exclude-file %h/.config/restic/excludes.conf --exclude-caches --tag "$BACKUP_TAGS" $BACKUP_PATHS
+
ExecStartPost={{ $resticPath }} forget --verbose --tag "$BACKUP_TAGS" --keep-daily "$RETENTION_DAYS" --keep-weekly "$RETENTION_WEEKS" --keep-monthly "$RETENTION_MONTHS" --keep-yearly "$RETENTION_YEARS"
+
ExecStopPost={{ $resticPath }} unlock --remove-all
+
TimeoutStopSec=2m
+
SendSIGKILL=false
+
SuccessExitStatus=3
+10
dot_config/systemd/user/restic-backup.timer
···
···
+
[Unit]
+
Description=Schedule a backup of the home directory
+
+
[Timer]
+
OnCalendar=daily
+
Persistent=true
+
AccuracySec=30m
+
+
[Install]
+
WantedBy=timers.target