mdxp / knife-backup

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

JSON error on restore #27

Closed thieman closed 10 years ago

thieman commented 10 years ago

I was getting the following error when trying to restore using 0.0.9:

knife backup -VV restore -D /Users/travis/chef-backup -c /gc/gcchef/.chef/knife-new.rb
WARNING: This will overwrite existing data!
Do you want to restore backup, possibly overwriting exisitng data? (Y/N)Y
/Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/knife-backup-0.0.9/lib/chef/knife/backup_restore.rb:116:in `clients': undefined method `create_id=' for JSON:Module (NoMethodError)
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/knife-backup-0.0.9/lib/chef/knife/backup_restore.rb:52:in `block in run'
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/knife-backup-0.0.9/lib/chef/knife/backup_restore.rb:52:in `each'
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/knife-backup-0.0.9/lib/chef/knife/backup_restore.rb:52:in `run'
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/chef-11.14.0.rc.2/lib/chef/knife.rb:493:in `run_with_pretty_exceptions'
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/chef-11.14.0.rc.2/lib/chef/knife.rb:174:in `run'
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/chef-11.14.0.rc.2/lib/chef/application/knife.rb:139:in `run'
    from /Users/travis/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/chef-11.14.0.rc.2/bin/knife:25:in `<top (required)>'
    from /Users/travis/.rvm/gems/ruby-2.1.1/bin/knife:23:in `load'
    from /Users/travis/.rvm/gems/ruby-2.1.1/bin/knife:23:in `<main>'
    from /Users/travis/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
    from /Users/travis/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'

I am a total Ruby novice, but I was able to fix this for myself by adding require 'JSON' to the top of backup_restore.rb. Didn't want to send a PR because I figured there was probably something fundamentally wrong with that approach.

danielgranat commented 10 years ago

:+1: Can't tell if that's fundamentally wrong, but thanks for posting. It helped me resolve this quickly :)

MichaelKueller commented 10 years ago

I had the same problem. This seems to be a bug. Thanks for pointing out a solution. In my case I had to add: require 'json' (lowercase)

hatchetation commented 10 years ago

:+1:

Same problem and solution here, with chef (= 11.14.6).

More details on the changes causing this are in #28 by @kbruner .

thieman commented 10 years ago

Seems like this has been fixed by https://github.com/mdxp/knife-backup/pull/28.