2023-09-01 15:42:25 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-09-01 15:42:25 -04:00
|
|
|
# Backup the PVC databases
|
2023-09-01 15:42:25 -04:00
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
BACKUP_DIR="/srv/backups/"
|
|
|
|
DATE="$( date +%Y%m%d )"
|
2023-09-01 15:42:25 -04:00
|
|
|
HOSTNAME="$( hostname -s )"
|
2023-09-01 15:42:25 -04:00
|
|
|
|
2023-09-01 15:42:25 -04:00
|
|
|
ZK_BACKUP_FILENAME_BASE="pvc-zookeeper-backup"
|
|
|
|
ZK_BACKUP_FILENAME="${BACKUP_DIR}/${ZK_BACKUP_FILENAME_BASE}.${DATE}.json.xz"
|
|
|
|
|
|
|
|
pvc -c local task backup | nice xz > ${ZK_BACKUP_FILENAME}
|
|
|
|
find ${BACKUP_DIR} -type f -name "${ZK_BACKUP_FILENAME_BASE}*" -mtime +7 -exec rm {} \;
|
|
|
|
|
|
|
|
DB_BACKUP_FILENAME_BASE="pvc-postgresql-backup"
|
|
|
|
DB_BACKUP_FILENAME="${BACKUP_DIR}/${DB_BACKUP_FILENAME_BASE}.${DATE}.sql.xz"
|
|
|
|
|
|
|
|
su postgres -c "pg_dumpall" | nice xz > ${DB_BACKUP_FILENAME}
|
|
|
|
find ${BACKUP_DIR} -type f -name "${DB_BACKUP_FILENAME_BASE}*" -mtime +7 -exec rm {} \;
|