# How to rollback to the previous chef cookbook version

**URL:** <https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155>\
**Category:** Chef Infra (archive)\
**Created:** [August 14, 2016, 12:06am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155 "2016-08-14T00:06:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheffy](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@cheffy](https://discourse.chef.io/u/cheffy)\
**Post date:** [August 14, 2016, 12:06am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/1 "2016-08-14T00:06:49Z")

</div>

Hi,

Example I have a cookbook with the version 1.2.8.4. I uploaded to chef server. I realized I did something wrong with the cookbook content how do i rollback to previous version 1.2.8.3. Since this is production cookbook I do not want to take risk uploading wrong cookbook. I just changed the cookbook version in the metadata.rb still I see chef-server is using my recent cookbook I uploaded 1.2.8.4.

Does anyone have have suggestions to do better.

Thanks  
Chefy

---

<div class="post-metadata">

**Author:** ![fulliautomatix](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fulliautomatix](https://discourse.chef.io/u/fulliautomatix)\
**Post date:** [August 14, 2016, 12:20am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/2 "2016-08-14T00:20:38Z")

</div>

Use Git.

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [August 14, 2016, 3:44am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/3 "2016-08-14T03:44:41Z")

</div>

You can use `knife cookbook delete` to remove the broken version from your Chef Server. If you don’t want to delete it, you can also use environment restrictions to lock that node down to force the older version, though this might be tricky if you aren’t already using chef environments. Also check out the `knife-solve` plugin to see which version of each cookbook is going to be used on a node.

---

<div class="post-metadata">

**Author:** ![nclemons](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/nclemons/32/3374_2.png) [@nclemons](https://discourse.chef.io/u/nclemons)\
**Post date:** [August 14, 2016, 4:05am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/4 "2016-08-14T04:05:20Z")

</div>

Knife cookbook delete

Then select 1.2.8.4 to remove.

Nathan Clemons  
DevOps Engineer  
Moxie Cloud Services (MCS)

O +1.425.467.5075  
M +1.360.861.6291  
E [nclemons@gomoxie.com](mailto:nclemons@gomoxie.com)  
W [www.gomoxie.com](http://www.gomoxie.com)[http://www.gomoxie.com/](http://www.gomoxie.com/)

---

<div class="post-metadata">

**Author:** ![losmi](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@losmi](https://discourse.chef.io/u/losmi)\
**Post date:** [August 14, 2016, 8:48am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/5 "2016-08-14T08:48:48Z")

</div>

Hey, use `knife cookbook delete <cookbok>@<version>` to remove specific version of cookbook.

---

<div class="post-metadata">

**Author:** ![cheffy](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@cheffy](https://discourse.chef.io/u/cheffy)\
**Post date:** [August 17, 2016, 4:43am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/6 "2016-08-17T04:43:58Z")

</div>

> [@losmi](#):
>
> remove

Sorry, I do not want to delete the present cookbook, and I want to roll back to the previous version without deleting the current version.

---

<div class="post-metadata">

**Author:** ![nathenharvey](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/nathenharvey/32/964_2.png) [@nathenharvey](https://discourse.chef.io/u/nathenharvey)\
**Post date:** [August 17, 2016, 12:49pm UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/7 "2016-08-17T12:49:51Z")

</div>

@cheffy,

The `knife cookbook delete` command will remove the cookbook from the Chef Server. You may specify both the name of the cookbook and the version of the cookbook you would like to delete. When you specify a version, only that version of the cookbook will be removed from the Chef Server. All other versions of the cookbook will remain on the Chef Server.

The `knife cookbook delete` command will not change any of the files you have locally. You will still have the current version on your local file system.

Based on my understanding of your initial question I believe this is what you are looking for. Perhaps we need more detail about the exact thing you are trying to accomplish?

Thanks,  
Nathen

---

<div class="post-metadata">

**Author:** ![375gnu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/375gnu/32/1463_2.png) [@375gnu](https://discourse.chef.io/u/375gnu)\
**Post date:** [August 18, 2016, 2:23pm UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/8 "2016-08-18T14:23:39Z")

</div>

pin cookbook version in enviroment

---

<div class="post-metadata">

**Author:** ![cheffy](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@cheffy](https://discourse.chef.io/u/cheffy)\
**Post date:** [September 12, 2016, 1:25am UTC](https://discourse.chef.io/t/how-to-rollback-to-the-previous-chef-cookbook-version/9155/9 "2016-09-12T01:25:04Z")

</div>

Thanks @nathenharvey
