Add daily Postgres vacuum script

This commit is contained in:
2019-08-11 15:29:00 -04:00
committed by Joshua Boniface
parent 6b491e529d
commit 030a3ded99
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#!/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