mdxp / knife-backup

knife plugin to help backup and restore a chef server.
Apache License 2.0
110 stars 45 forks source link

Restore only uploads newest cookbook #36

Closed defunctknightsurfer closed 9 years ago

defunctknightsurfer commented 9 years ago

I am attempting a restore and it seems like everything worked correctly except when it restored the cookbooks. It looks like it is trying to restore each version, but only really restores the newest version of the cookbook. The below example happened with every cookbook.

Restoring cookbook ["yum-repoforge"]
WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
WARNING: The cookbooks: yum-repoforge, yum-repoforge exist in multiple places in your cookbook_path.
A composite version of these cookbooks has been compiled for uploading.

IMPORTANT: In a future version of Chef, this behavior will be removed and you will no longer
be able to have the same version of a cookbook in multiple places in your cookbook_path.
WARNING: The affected cookbooks are located:
yum-repoforge:
  /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge
  /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.4.0
  /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.5.0
WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
Uploading yum-repoforge  [0.5.0]
Uploaded 1 cookbook.
Restoring cookbook ["yum-repoforge"]
WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
WARNING: The cookbooks: yum-repoforge, yum-repoforge exist in multiple places in your cookbook_path.
A composite version of these cookbooks has been compiled for uploading.

IMPORTANT: In a future version of Chef, this behavior will be removed and you will no longer
be able to have the same version of a cookbook in multiple places in your cookbook_path.
WARNING: The affected cookbooks are located:
yum-repoforge:
  /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge
  /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.4.0
  /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.5.0
WARNING: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
Uploading yum-repoforge  [0.5.0]
Uploaded 1 cookbook.

I checked the metadata in the cookbooks to make sure they were correct.

$ grep version /Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.*.0/metadata.json 
/Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.4.0/metadata.json:  "version": "0.4.0",
/Users/pkringle/chef-backup_20150325/cookbooks/yum-repoforge-0.5.0/metadata.json:  "version": "0.5.0",

I am using chef / knife version

$ knife --version
Chef: 12.1.1

And restoring to chef server version 11.1.6-1 on Ubuntu 14.04

Thoughts? Is it something I am doing?

Thanks.

defunctknightsurfer commented 9 years ago

BTW, I did see a post here https://www.coveros.com/forklifting-chef-server/

He describes my problem but I haven't tested his fix yet.

mdxp commented 9 years ago

Thanks for this. Let me know how it goes. I haven't had time to try knife backup against a chef12 server or client, but I plan to do that as soon as I find some time to setup one.

defunctknightsurfer commented 9 years ago

Looks like modification to the backup_restore.rb fixed the problem. If you would like I can submit a pull request but I feel a little bad since I didn't write the code, just coping it :)

mrjcleaver commented 9 years ago

@pkringle - I just ran into the same set of issues - thanks to Coveros for documenting the workaround!

Yes, it would have been best if they had submitted a PR. I just emailed info @ coveros as Glenn's article omitted a link back to code.

Personally I don't think there is any shame in doing a PR of anyone else's patch as long as you acknowledge it.

mrjcleaver commented 9 years ago

@pkringle - did the patch apply cleanly for you? I get:

$ cd ~/.chefdk/gem/ruby/2.1.0/gems/knife-backup-0.0.10/lib/chef/knife 
$ patch <backup_restore.patch 
patching file backup_restore.rb
patch: **** malformed patch at line 18: @@ -172,12 +175,15 @@
defunctknightsurfer commented 9 years ago

I can't remember for sure, but I think I had to manually modify the code though as I don't think the patch worked cleanly as you stated.

pmoosh commented 9 years ago

Fixed with (#38)[https://github.com/mdxp/knife-backup/commit/9990c14ee5eb04875b2291f24e0491aa63c023b4]