Created
April 5, 2017 10:26
-
-
Save dobrivoje/fd907b914c51cfdfdf8682de05a61817 to your computer and use it in GitHub Desktop.
vacuum.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### !/bin/bash | |
CLIENT="Server name" | |
DBNAME="postgres_database_Name" | |
POSTGRESAUTH="postgres" | |
PGPASSWORD="db password" | |
MODE=full | |
TO1="[email protected]" | |
TO2="[email protected]" | |
SUBJ="$CLIENT, baza: $DBNAME, full vacuum završen" | |
S="$CLIENT - $MODE vaccum for database $DBNAME" | |
LOG="/root/scripts/logs/vacuum_full.log" | |
export PGPASSWORD | |
echo "[`date '+%X'`] Vacuum start, CLIENT: $CLIENT, database: $DBNAME " >> $LOG | |
### Commands below will send emails and notify users that job has begun | |
cat "$S - Start" | `sh /root/scripts/mail/posaljimail44.sh $TO1 "$S - Start"` | |
cat "$S - Start" | `sh /root/scripts/mail/posaljimail44.sh $TO2 "$S - Start"` | |
### psql $DBNAME -h localhost -U $POSTGRESAUTH -f /root/scripts/vacuum_full.sh >> $LOG | |
nice -19 vacuumdb --host=localhost --port=5432 --dbname=$DBNAME --username=$POSTGRESAUTH --$MODE --verbose | |
echo "$S - Finished." >> $LOG | |
### Commands below will send emails and notify users that job is done | |
cat $LOG | tail -n 3 | `sh /root/scripts/mail/posaljimail44.sh "$TO1" "$SUBJ" ` | |
cat $LOG | tail -n 3 | `sh /root/scripts/mail/posaljimail44.sh "$TO2" "$SUBJ" ` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment