13 lines
626 B
Bash
Executable file
13 lines
626 B
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
umask 077
|
|
[[ $# == 1 && -d $1 ]] || { echo 'Usage: db-backup-daily.sh /absolute/backup-directory' >&2; exit 1; }
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
# Serialize daily runs to bound space usage. On failure retain dump for diagnosis.
|
|
exec 9>"$1/.randomayzer-backup.lock"
|
|
flock -n 9 || exit 0
|
|
backup=$("$root/tools/db-backup.sh" "$1")
|
|
"$root/tools/db-restore-check.sh" "$backup"
|
|
# Retain fourteen daily backups; only this application's named dumps are eligible.
|
|
find "$1" -maxdepth 1 -type f -name 'randomayzer-*.dump' -mtime +14 -delete
|
|
echo 'PASS daily backup and restore verification'
|