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