Scott Baker | 32bc6b6 | 2013-08-20 16:37:33 -0700 | [diff] [blame] | 1 | #! /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 | |
| 7 | mkdir -p /opt/planetstack/ovs-backups |
| 8 | BACKUP_NAME=/opt/planetstack/ovs-backups/backup-`date "+%Y-%M-%d"`.sql |
| 9 | mysqldump --create-options --routines --triggers --databases keystone ovs_quantum nova glance cinder > $BACKUP_NAME |
| 10 | gzip $BACKUP_NAME |
| 11 | |
| 12 | mysql keystone -e "DELETE FROM token WHERE NOT DATE_SUB(CURDATE(),INTERVAL 2 DAY) <= expires;" |
| 13 | mysqlcheck --optimize --databases keystone ovs_quantum nova glance cinder |
| 14 | |
| 15 | date >> /var/log/openstack-db-cleanup.log |
| 16 | mysql keystone -e "select count(*) from token;" >> /var/log/openstack-db-cleanup.log |