init: initial commit
This commit is contained in:
commit
d2258d5808
10 changed files with 235 additions and 0 deletions
13
common/restic/backup.sh
Normal file
13
common/restic/backup.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
/neb/common/ntfy.sh -m "performing backup..." -e "warning" https://push.ixvd.net/infra-backups
|
||||
if restic \
|
||||
-r "sftp://ixvd_backup_storage//backups/restic-$(hostname)" \
|
||||
-p "/neb/secrets/restic/$(hostname).secret" \
|
||||
backup \
|
||||
--tag auto \
|
||||
/srv /home /etc; then
|
||||
/neb/common/ntfy.sh -m "backup succeeded" -e "warning" https://push.ixvd.net/infra-backups
|
||||
else
|
||||
/neb/common/ntfy.sh -p "urgent" -m "backup failed" -e "warning,skull" https://push.ixvd.net/infra-backups
|
||||
fi
|
25
common/restic/forget.sh
Normal file
25
common/restic/forget.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/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
|
13
common/restic/prune.sh
Normal file
13
common/restic/prune.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
notify() {
|
||||
curl \
|
||||
-X POST \
|
||||
-H "Title: $0" \
|
||||
-H "Priority: urgent" \
|
||||
-H "Tags: warning" \
|
||||
-d "$(hostname): $@" \
|
||||
https://push.ixvd.net/infra-backups
|
||||
}
|
||||
|
||||
notify "pruning old backups..."
|
10
common/restic/restic.crontab
Normal file
10
common/restic/restic.crontab
Normal file
|
@ -0,0 +1,10 @@
|
|||
# /etc/cron.d/restic.crontab
|
||||
|
||||
# every 4 hours create a backup
|
||||
0 */4 * * * root /neb/common/restic/backup.sh
|
||||
|
||||
# every day at 2 in the morning, forget old backups
|
||||
0 2 * * * root /neb/common/restic/forget.sh
|
||||
|
||||
# every 1st of the month at 2 in the morning, prune
|
||||
0 2 1 * * root /neb/common/restic/prune.sh
|
Loading…
Add table
Add a link
Reference in a new issue