Compare commits

...

7 Commits

Author SHA1 Message Date
drunkendog bafd045a5f Replace ! -z with -n 2023-08-14 17:26:27 +01:00
drunkendog 8e33572053 Fix string concatenation 2023-08-14 15:01:58 +01:00
drunkendog 6e8539b758 Add failure modes and runtime to healthcheck 2023-08-14 14:15:12 +01:00
drunkendog c31b585220 Only call healthcheck if backup finished without errors 2023-08-14 12:38:33 +01:00
drunkendog 3b68481bd0 Add 'backup/readme.md' 2023-08-14 12:35:59 +01:00
drunkendog 64eb9cb3cf Update 'backup/backup-script.sh' 2023-08-14 12:33:05 +01:00
drunkendog ecb87cf031 Add healthcheck url to borg config initializer 2023-08-14 12:30:49 +01:00
3 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,10 @@
. /etc/backup.conf
if [ -n "$HEALTHCHECK_URL" ]; then
curl -L "{$HEALTHCHECK_URL}/start"
fi
# some helpers and error handling:
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
@ -63,4 +67,8 @@ else
info "Backup, Prune, and/or Compact finished with errors"
fi
if [ -n "$HEALTHCHECK_URL" ]; then
curl -L "{$HEALTHCHECK_URL}/{$global_exit}"
fi
exit ${global_exit}

View File

@ -19,9 +19,12 @@ assert getpass.getpass("Confirm passhphrase: ").rstrip() == secret_seed, "Passph
salted_secret_seed = hostname + secret_seed
salted_hash_value = hashlib.sha512(salted_secret_seed.encode())
healthcheck_url = input("Enter healthcheck url: ").rstrip()
with open("/etc/backup.conf", "w") as f:
f.write(f"export BORG_REPO='ssh://{hostname}@{server_hostname}.162536.xyz:22/~/backup/docker'\n")
f.write(f"export BORG_PASSPHRASE='{salted_hash_value.hexdigest()}'\n")
f.write(f"export HEALTHCHECK_URL='{healthcheck_url}'\n")
os.system("ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"")

6
backup/readme.md Normal file
View File

@ -0,0 +1,6 @@
# Backups
Example cron:
```sh
32 * * * * /bin/sh /root/standard-build/backup/backup-script.sh >/root/last-backup-log.txt 2>&1
```