## Clean up items older than 30 days

This script executes every day at midnight.

### Installiation

* Upload script to the server:
```shell
scp main.sh dev-infra-sentry-01:sentry-cleanup.sh
```
* Make it executable on the remote server
```shell
ssh dev-infra-sentry-01
chmod +x sentry-cleanup.sh
```
* Add it to crontab on the remote server
```shell
ssh dev-infra-sentry-01
crontab -e
# in the editor add the following string without # in the beginning, save changes and exit.
# 0 0 * * * /home/ec2-user/sentry-cleanup.sh >> /home/ec2-user/sentry-cleanup.log 2>&1 
```

### Database 

In addition to this script it makes sense to run the following query against database

* Connect to the database:
```postgresql
docker run -ti --rm postgres:10.13 psql -h dev-infra-sentry-db.cvszyfzpojr4.us-east-1.rds.amazonaws.com -U sentry_usr -W sentry_db
```
* Run the query:
```postgresql
VACUUM (ANALYZE, VERBOSE);
```
