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