Make vacuum script more comprehensive

This commit is contained in:
2023-09-01 15:42:21 -04:00
parent 8163769183
commit 7689e659fe
3 changed files with 27 additions and 12 deletions

View File

@ -1,6 +1,14 @@
#!/bin/bash
# Daily vaccuum script for PostgreSQL databases
# {{ ansible_managed }}
# Daily vaccuum script for PVC daemons
# Ansible managed - last modified on 2019-08-12 13:20:15
# This script cleans up the PostgreSQL databases as well as the Zookeeper
# database. This prevents filesystem growth balooning after loong running
# periods.
#
# PostgreSQL
#
# Don't run if we aren't the Patroni primary
HOSTNAME="$( hostname -s )"
@ -11,7 +19,14 @@ if [[ $HOSTNAME != $PRIMARY ]]; then
fi
# Analyze the database
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log
echo -e "$( date )" &>>/var/log/pvc/pdns/vacuum.log
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log
su postgres -c 'vacuumdb --verbose --analyze --all' &>>/var/log/pvc/pdns/vacuum.log
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
echo -e "$( date )" &>>/var/log/pvc/vacuum.log
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
su postgres -c 'vacuumdb --verbose --analyze --all' &>>/var/log/pvc/vacuum.log
#
# Zookeeper
#
export ZOOCFG=/etc/zookeeper/conf/zoo.cfg
/usr/share/zookeeper/bin/zkCleanup.sh -n 7 &>>/var/log/pvc/vacuum.log