.dots/scripts/restic/prune.sh
2024-08-30 10:21:15 +02:00

23 lines
826 B
Bash
Executable file

#!/usr/bin/env zsh
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
# check if we're running in a subshell, forbid direct execution
[[ "$ZSH_EVAL_CONTEXT" == "toplevel" ]] && printf "error: direct execution of this script is forbidden!\n" >&2 && exit 1
# define title and icon for the notification
export RESTIC_NTFY_TITLE="prune"
export RESTIC_NTFY_ICON="red_circle"
printf ">> pruning repository '"$RESTIC_REPOSITORY"'...\n\n"
# execute "pre" action if defined
[[ -n "$RESTIC_PRUNE_PRE" ]] && eval "$RESTIC_PRUNE_PRE"
sudo --preserve-env -u "$RESTIC_USER" restic forget --keep-daily 7 --keep-weekly 1 --keep-monthly 1 --prune --retry-lock 3h
# execute "post" action if defined
[[ -n "$RESTIC_PRUNE_POST" ]] && eval "$RESTIC_PRUNE_POST"
printf "\n>> repository pruned after "$SECONDS" seconds!\n"