Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. ### !/bin/bash
  2. CLIENT="Server name"
  3. DBNAME="postgres_database_Name"
  4. POSTGRESAUTH="postgres"
  5. PGPASSWORD="db password"
  6. MODE=full
  7.  
  8. TO1="first_email@email.com"
  9. TO2="second_email@email.com"
  10. SUBJ="$CLIENT, baza: $DBNAME, full vacuum završen"
  11. S="$CLIENT - $MODE vaccum for database $DBNAME"
  12.  
  13. LOG="/root/scripts/logs/vacuum_full.log"
  14. export PGPASSWORD
  15.  
  16. echo "[`date '+%X'`] Vacuum start, CLIENT: $CLIENT, database: $DBNAME " >> $LOG
  17.  
  18. ### Commands below will send emails and notify users that job has begun
  19. cat "$S - Start" | `sh /root/scripts/mail/posaljimail44.sh $TO1 "$S - Start"`
  20. cat "$S - Start" | `sh /root/scripts/mail/posaljimail44.sh $TO2 "$S - Start"`
  21.  
  22. ### psql $DBNAME -h localhost -U $POSTGRESAUTH -f /root/scripts/vacuum_full.sh >> $LOG
  23.  
  24. nice -19 vacuumdb --host=localhost --port=5432 --dbname=$DBNAME --username=$POSTGRESAUTH --$MODE --verbose
  25.  
  26. echo "$S - Finished." >> $LOG
  27.  
  28. ### Commands below will send emails and notify users that job is done
  29. cat $LOG | tail -n 3 | `sh /root/scripts/mail/posaljimail44.sh "$TO1" "$SUBJ" `
  30. cat $LOG | tail -n 3 | `sh /root/scripts/mail/posaljimail44.sh "$TO2" "$SUBJ" `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement