Add daily Postgres vacuum script
This commit is contained in:
16
roles/pvc/templates/patroni/pvcdns-vacuum.j2
Normal file
16
roles/pvc/templates/patroni/pvcdns-vacuum.j2
Normal 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
|
Reference in New Issue
Block a user