pvc-ansible/roles/pvc/templates/patroni/pvcdns-vacuum.j2

17 lines
653 B
Plaintext
Raw Normal View History

2019-08-11 15:29:00 -04:00
#!/bin/bash
# Daily vaccuum script for PVCDNS database
# {{ ansible_managed }}
# Don't run if we aren't primary
HOSTNAME="$( hostname -s )"
PRIMARY="$( pvc node list | grep primary | awk '{ print $1 }' )"
if [[ $HOSTNAME != $PRIMARY ]]; then
exit 0
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 'psql pvcdns -c "VACUUM (VERBOSE, ANALYZE);"' &>>/var/log/pvc/pdns/vacuum.log