neb/common/restic/forget.sh

26 lines
608 B
Bash
Raw Normal View History

2023-10-18 01:31:05 +02:00
#!/bin/sh
notify() {
curl \
-X POST \
-H "Authorization: $(cat ${NTFY_SECRET_FILE:-/etc/ixvd/secrets/ntfy/infra-backups})" \
-d "$(hostname): $@" \
https://push.ixvd.net/infra-backups
}
notify "forgetting old backups..."
if restic \
-r "sftp://ixvd_backup_storage//backups/restic-$(hostname)" \
-p "/etc/ixvd/secrets/restic/$(hostname).secret" \
forget \
--keep-last 10 \
--keep-tag keep \
--keep-daily 20 \
--keep-weekly 20 \
--keep-monthly 6 \
--keep-yearly 10; then
notify "forget succeeded"
else
notify "forget failed"
fi