Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Let's say you have a standard Chef repository with directories as follows:


Is there way to upload it all in one go? Otherwise you have to do this:

knife cookbook upload -a
knife data bag from file data_bags/*.json
knife environment from file environments/*.rb
knife role from file roles/*.json

Perhaps there are third-party tools to do this kind of thing?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Make sure you are using ruby 1.9, then install knife-essentials

$ gem install knife-essentials

Then add the following to ~/.chef/knife.rb

repo_mode 'everything'
versioned_cookbooks true
chef_repo_path 'PATH/TO/chef-repo'

Then you can download/upload your entire server, or just parts of it. Downloading will put a lot of .json files in your chef-repo, good for backups I found.

$ knife download /
$ knife upload /
$ knife upload /clients

Also note that if you have roles stored as ruby files (e.g: roles/*.rb), you will need to convert them to json. Then you can re-download them from chef server as json. For example:

  1. knife role from file roles/*.rb
  2. knife download roles/

This method is also used to upgrade from chef server 10 to 11.

share|improve this answer

You could write a simple bash script to do that like:


for file in `ls cookbooks`;do
 [ -d $file ] && knife cookbook upload cookbooks/$file
for file in `ls data_bags | grep \.json$`;do
 knife data bag from file data_bags/$file
for file in `ls environments | grep \.rb$`;do
 knife environment from file environments/$file
for file in `ls roles | grep \.json$`;do
 knife role from file roles/$file

then call it using ./, this will do everything automatically.

share|improve this answer
Um, well, obviously. :/ – Steve Bennett Sep 6 '12 at 0:46

I wrote a small knife plugin called sync-all described below that accomplishes this as well:

share|improve this answer

Currently the docs say you should simply knife upload /. There are other possibilities in the docs.

share|improve this answer
This has less information than provided in the question (let alone the current accepted question) For a 3 year old question. – Reaces Jan 23 at 19:07
@Reaces There is no accepted answer. I pointed to the docs, which no one else did, and gave the correct answer. The correct answer has changed since the question was posed. The existing answers here are unnecessarily complicated. – mmell Jan 23 at 20:41
(I've accepted an answer now. I don't use Chef anymore, so I'm just trusting that CrackerJackMack's answer is valid.) – Steve Bennett Jan 27 at 4:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.