|
Manage Chef objects in Source ControlChef enables the reconstruction of your business from nothing but a source code repository, an application data backup, and bare metal machines. With Chef, you define in source code how each part of your infrastructure is built. Cookbooks, roles, data bags and environments should be created as JSON files in source control, and then uploaded to the Chef Server. Disaster recovery then becomes:
Using source control also means that previous versions are always available for restoration and provides a log for auditing changes. Export objects from the Chef server
This will export your data bags, roles, and nodes stored on the chef server as JSON files within the .chef/chef_server_backup directory. Simply copy that directory and all files within to your backup location, and you'll have all of the objects that you use within Chef available to you as JSON files. These files can be uploaded to a new Chef server using knife. CouchDB Backup
A minimal backup consists of configuration files and a dump of the CouchDB database. For all platforms, locate your database, configuration, and log files and perform a filesystem copy. Be careful to preserve file permissions, too. Archive these files to wherever you want-- ideally on a different machine in a different physical location – with appropriate security limiting access. For example, here are the directories to backup for a CouchDB install on Ubuntu:
You'll want to backup both the .couch database file (which contains many objects, including the index to the cookbooks) and the directory in 'checksum_path' specified in your server.rb, which contains the file contents. One possible example: The SOLR Search index the RabbitMQ queue Chef Indexer should be rebuilt upon restoration.
|
|
|


7 Comments
comments.show.hideDec 08, 2009
Joshua Timberman
There's a python-based couchdb dump tool available in Karmic, too.
Jan 05, 2011
Bich Le
Where does chef-server store the repo (cookbooks uploaded by clients?)
On my CentOS installation, /etc/chef/server.rb has this line:
cookbook_path [ "/var/lib/chef/cookbooks" ]
But that directory is empty on the server.
Does the server store cookbooks in couchdb?
Jan 06, 2011
Joshua Timberman
The cookbooks are stored in the directory location specified by the checksum_path setting in the config, which would go in /etc/chef/server.rb.
The default location is /var/chef/checksums, because the filenames are by the actual checksums of the file. We'll update this page and the Chef Configuration Settings.
Aug 12, 2011
Bryan McLellan
Parts of the cookbooks, such as the metadata, are stored in the couchdb database. These objects contain checksums for individual files in the cookbook such as recipes, where are stored in checksum_path. You can find this checksum from 'knife cookbook show COOKBOOK_NAME COOKBOOK_VERSION in the checksum field for the file, and then find it in the filesystem.
Feb 17, 2012
Kevin Duane
Is there a documented process for reloading couchdb from the couchdb-dump?
Mar 02, 2012
Ian D. Rossi
Thank you for Chef!
Of the three strategies mentioned at the top of this page, are all three necessary?
The way I am taking it is that you can do complete backup and recovery by managing Chef objects in a source code repository and backup up that repository.
I understand that data bags, roles, etc can be created from source code. But what about nodes and node attributes? Aren't those stored in chef-server and not in source code? How, then, does that data get restored?
Some node attributes would be restored when certain roles or cookbooks are applied, but what about attributes that are assigned to nodes with the "knife node edit NODE" command? I don't believe those are stored in source code. It seems that when you would try to restore everything from source code, node attributes applied by roles would be preserved but attributes applied directly to roles by "knife node edit NODE" would be lost. Is that correct?
If it IS possible to backup and restore chef-server only using a source code repository, is it still necessary to backup and restore CouchDB as described here?
Thanks again.
Warmest regards,
Ian D. Rossi
Mar 08, 2012
Ian D. Rossi
bump