system-config/playbooks/roles/borg-backup-server/files/verify-borg-backups.sh
Ian Wienand 0d01d941b1 borg-backup-server: run a weekly backup verification
This checks the backup archives and alerts us if anything seems wrong.
This will take a few hours, so we run once a week.

Change-Id: I832c0d29a37df94d4bf2704c59bb3f8d855c3cc8
2021-02-11 00:43:16 +00:00

23 lines
599 B
Bash

#!/bin/bash
pushd /opt/backups
for u in borg-*; do
BORG_REPO=/opt/backups/$u/backup
sudo BORG_RELOCATED_REPO_ACCESS_IS_OK=y BORG_REPO=${BORG_REPO} -u ${u} -s <<'EOF'
echo "$(date) Verifying ${BORG_REPO} ..."
/opt/borg/bin/borg check --verify-data
if [[ $? -ne 0 ]]; then
echo "$(date) *** Verification failed"
echo "Inconsistency found in backup ${BORG_REPO} on $(hostname) at $(date)" |
mail -s "ACTION REQUIRED: Backup inconsistency: ${BORG_REPO}" infra-root@openstack.org
else
echo "$(date) ... done"
echo
fi
EOF
done