
In today's weird corner-case issue; when running under cron, SHELL=/bin/sh ... which doesn't really matter (this script is run under #!/bin/bash) *except* that "sudo -s" is obeying SHELL and consequently the in-line script here fails under cron, but not when run interactively. Just set SHELL=/bin/bash for consistency. Change-Id: Ic8584b90fea8382f7a7d294b98a0a3689bfc981b
27 lines
721 B
Bash
27 lines
721 B
Bash
#!/bin/bash
|
|
|
|
# When under cron, SHELL can bin /bin/sh which the "sudo -s" below
|
|
# obeys. Let's just use bash.
|
|
export SHELL=/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
|