Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DB_HOST="db01"
- DB_USER="evergreen"
- PSQL="/usr/bin/psql"
- VACUUMDB="/usr/bin/vacuumdb"
- KEEP_ONE_YEAR="actor_usr_history"
- KEEP_SIX_MONTHS="actor_usr_address_history"
- KEEP_THREE_MONTHS="asset_call_number_history asset_copy_history biblio_record_entry_history"
- INTERVAL="1 year"
- for table in $KEEP_ONE_YEAR; do
- $PSQL -U $DB_USER -h $DB_HOST -c "DELETE FROM auditor.$table WHERE audit_time < now() - '$INTERVAL'::interval"
- PGHOST=$DB_HOST PGUSER=$DB_USER $VACUUMDB --analyze --table auditor.$table
- done
- INTERVAL="6 months"
- for table in $KEEP_SIX_MONTHS; do
- $PSQL -U $DB_USER -h $DB_HOST -c "DELETE FROM auditor.$table WHERE audit_time < now() - '$INTERVAL'::interval"
- PGHOST=$DB_HOST PGUSER=$DB_USER $VACUUMDB --analyze --table auditor.$table
- done
- INTERVAL="3 months"
- for table in $KEEP_THREE_MONTHS; do
- $PSQL -U $DB_USER -h $DB_HOST -c "DELETE FROM auditor.$table WHERE audit_time < now() - '$INTERVAL'::interval"
- PGHOST=$DB_HOST PGUSER=$DB_USER $VACUUMDB --analyze --table auditor.$table
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement