pvc-ansible/roles/base/templates/etc/cron.daily/mon-backup.j2

25 lines
543 B
Plaintext
Raw Normal View History

2022-11-05 01:56:48 -04:00
#!/bin/bash
# Backup the Ceph monitor data
# {{ ansible_managed }}
set -o errexit
BACKUP_DIR="/srv/backups"
DATE="$( date +%Y%m%d )"
HOSTNAME="$( hostname -s )"
if [[ ! -d ${BACKUP_DIR} ]]; then
mkdir -p ${BACKUP_DIR}
fi
pushd ${BACKUP_DIR} &>/dev/null
MON_BACKUP_FILENAME_BASE="ceph-mon-backup"
MON_BACKUP_FILENAME="${BACKUP_DIR}/${MON_BACKUP_FILENAME_BASE}.${DATE}.tar.xz"
tar -cJf ${MON_BACKUP_FILENAME} /var/lib/ceph/mon
find ${BACKUP_DIR} -type f -name "${MON_BACKUP_FILENAME_BASE}*" -mtime +7 -exec rm {} \;
popd &>/dev/null