blob: 9baca6e3c56b1d1132838f607bd868de59078881 [file] [log] [blame]
Scott Baker32bc6b62013-08-20 16:37:33 -07001#! /bin/bash
2
3# to install
4# chmod 0755 /opt/planetstack/openstack/openstack-db-cleanup.sh
5# ln -s /opt/planetstack/openstack/openstack-db-cleanup.sh /etc/cron.daily/openstack-db-cleanup.cron
6
7mkdir -p /opt/planetstack/ovs-backups
8BACKUP_NAME=/opt/planetstack/ovs-backups/backup-`date "+%Y-%M-%d"`.sql
9mysqldump --create-options --routines --triggers --databases keystone ovs_quantum nova glance cinder > $BACKUP_NAME
10gzip $BACKUP_NAME
11
12mysql keystone -e "DELETE FROM token WHERE NOT DATE_SUB(CURDATE(),INTERVAL 2 DAY) <= expires;"
13mysqlcheck --optimize --databases keystone ovs_quantum nova glance cinder
14
15date >> /var/log/openstack-db-cleanup.log
16mysql keystone -e "select count(*) from token;" >> /var/log/openstack-db-cleanup.log