restic backups ftw
This commit is contained in:
parent
af4c606e75
commit
81c93a1bf8
6 changed files with 89 additions and 0 deletions
32
home/private_bin/executable_restic-othalan
Normal file
32
home/private_bin/executable_restic-othalan
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -a
|
||||
source "$HOME/.config/restic/othalan.env"
|
||||
declare -a flags
|
||||
|
||||
# if [[ "$1" == "backup" ]]; then
|
||||
# flags=(
|
||||
# "--exclude-file" "$HOME/.config/restic/excludes.txt"
|
||||
# "--exclude-file" "$HOME/.conda/environments.txt"
|
||||
# )
|
||||
# fi
|
||||
#
|
||||
# echo "${flags[@]}"
|
||||
# assumes subcommand always comes first
|
||||
case $1 in
|
||||
-*) restic "$@" && exit "$?";;
|
||||
backup) cmd=backup; shift;;
|
||||
*) cmd="$1"; shift;;
|
||||
esac
|
||||
|
||||
if [[ $cmd == "backup" ]]; then
|
||||
flags=(
|
||||
"--exclude-file" "$HOME/.config/restic/excludes.txt"
|
||||
"--exclude-file" "$HOME/.conda/environments.txt"
|
||||
)
|
||||
fi
|
||||
|
||||
|
||||
# echo restic "$@" "${flags[@]}"
|
||||
|
||||
restic "$cmd" "${flags[@]}" "$@"
|
11
home/private_dot_config/restic/othalan.env
Normal file
11
home/private_dot_config/restic/othalan.env
Normal file
|
@ -0,0 +1,11 @@
|
|||
RESTIC_REPOSITORY=rclone:g:othalan
|
||||
RESTIC_PASSWORD_FILE=/home/daylin/.config/restic/othalan-pass
|
||||
BACKUP_EXCLUDES="
|
||||
--exclude-file /home/daylin/.config/restic/excludes.txt
|
||||
--exclude-file /home/daylin/.conda/environments.txt
|
||||
"
|
||||
RETENTION_DAYS=7
|
||||
RETENTION_WEEKS=4
|
||||
RETENTION_MONTHS=6
|
||||
RETENTION_YEARS=3
|
||||
BACKUP_PATHS="/home/daylin/dev /home/daylin/stuff"
|
21
home/private_dot_config/systemd/user/restic-backup.service
Normal file
21
home/private_dot_config/systemd/user/restic-backup.service
Normal file
|
@ -0,0 +1,21 @@
|
|||
;ref: https://fedoramagazine.org/automate-backups-with-restic-and-systemd/
|
||||
|
||||
[Unit]
|
||||
Description=Restic backup service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=restic backup \
|
||||
--verbose \
|
||||
--one-file-system \
|
||||
--tag systemd.timer \
|
||||
$BACKUP_EXCLUDES $BACKUP_PATHS
|
||||
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
|
||||
EnvironmentFile=%h/.config/restic/othalan.env
|
9
home/private_dot_config/systemd/user/restic-backup.timer
Normal file
9
home/private_dot_config/systemd/user/restic-backup.timer
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Backup with restic daily
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -0,0 +1,7 @@
|
|||
[Unit]
|
||||
Description=Restic backup service (data pruning)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=restic prune
|
||||
EnvironmentFile=%h/.config/restic/othalan.env
|
9
home/private_dot_config/systemd/user/restic-prune.timer
Normal file
9
home/private_dot_config/systemd/user/restic-prune.timer
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Prune data from the restic repository monthly
|
||||
|
||||
[Timer]
|
||||
OnCalendar=monthly
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in a new issue