Chef Server Maintenance

Standard

Chef Server maintenance

 

Backups

 

A minimal backup consists of configuration files and a dump of the CouchDB database. The solr index can be rebuilt and the RabbitMQ queue is not important unless you want instant failover.

tar -czf /tmp/chef_server_backup.`date +%F`.tar.gz /var/lib/chef /etc/chef /etc/couchdb
couchdb-dump http://127.0.0.1:5984/chef |gzip -9c > /tmp/chef.`date +%F`.couchdb.gz

 

CouchDB cleanup

 

CouchDB is very disk-space hungry. It needs regular compaction for database and views as well as cleanups for each view.

#! /bin/sh
/usr/bin/curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_compact
/usr/bin/curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_view_cleanup
for view in registrations sandboxes id_map clients checksums cookbooks data_bags nodes roles users; do
        /usr/bin/curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_compact/$view
done