Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

1.5 KB
Raw Blame
#!/usr/bin/env bash
# Weekly restore test (linedesk-restore-test.timer). Unencrypted backups: the newest is restored into a throwaway
# database and compared with the live one (scripts/restore-backup.sh). Encrypted backups (BACKUP_AGE_RECIPIENT in
# backup.env): the private key stays off the server, so only what can be checked without it: the newest backup is
# there, not tiny, and starts with an age header. A full restore of those is done by hand with the key (docs/self-hosting.md, Backups).
set -euo pipefail
[ -r /etc/linedesk/ops.env ] && . /etc/linedesk/ops.env
cd "${LINEDESK_APP_DIR:-/opt/linedesk/app}"
# shellcheck source=/dev/null
. scripts/backup-settings.sh
if [ -z "$(setting BACKUP_AGE_RECIPIENT)" ]; then
  exec scripts/restore-backup.sh
fi
prefix=$(setting BACKUP_S3_PREFIX); prefix=${prefix:-linedesk/}
work=$(mktemp -d); trap 'rm -rf "$work"' EXIT # rclone (backup-settings.sh) mounts it
newest=$(scripts/backup.sh --list | awk '{print $1, $NF}' | grep -E ' linedesk-[0-9]{8}T[0-9]{6}Z\.dump\.age$' | sort -k2 | tail -1)
[ -n "$newest" ] || { echo "no encrypted backup found in the bucket"; exit 1; }
size=${newest%% *} name=${newest#* }
[ "$size" -gt 10000 ] || { echo "$name is only $size bytes"; exit 1; }
header=$(rclone cat --count 21 "b:$(setting BACKUP_S3_BUCKET)/${prefix%/}/$name")
[ "$header" = "age-encryption.org/v1" ] || { echo "$name does not start with an age header"; exit 1; }
echo "$name: $size bytes, age-encrypted; full restore test needs the private key (docs/self-hosting.md, Backups)"