Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node knife attributes doesn't get populated after restore #57

Open
aniruddhanavare opened this issue Jun 16, 2016 · 8 comments
Open

Node knife attributes doesn't get populated after restore #57

aniruddhanavare opened this issue Jun 16, 2016 · 8 comments

Comments

@aniruddhanavare
Copy link

aniruddhanavare commented Jun 16, 2016

I am using knife backup - restore plugin with following configuration

knife plugin version : 0.0.12
chef server version : 11.18.12

It has been found that, after restore, certain node attributes are not visible when we do "knife show node" command.

I have virtual machine, which has following attributes.

Command : knife node show falRhel6x64.ammpilot.FALCON.release.ibm.com
Output

Node Name: falRhel6x64.ammpilot.FALCON.release.ibm.com
Environment: _default
FQDN: falRhel6x64.ammpilot.FALCON.release.ibm.com
IP: 159.8.215.239
Run List: recipe[zabbix-agent::linux], role[SetupPatchingNode]
Roles: ScanForPatches
Recipes: patchservice_operations::ScanEndpoints
Platform: redhat 7.2
Tags:

When I do backup using knife backup and proceed with restore operation, same node shows following attributes when it is queried

[root@localhost ~]# knife node show falRhel6x64.ammpilot.FALCON.release.ibm.com
Node Name: falRhel6x64.ammpilot.FALCON.release.ibm.com
Environment: _default
FQDN:
IP:
Run List: recipe[zabbix-agent::linux], role[SetupPatchingNode]
Roles:
Recipes:
Platform:
Tags:

If you see, certain attributes are missing. It has been seen that, certain JSON block is missing.

@aniruddhanavare
Copy link
Author

backupIssue1.tar.gz

@aniruddhanavare
Copy link
Author

It has been seen that, certain JSON block is missing during BACKUP of the this particular entry. Other entries are working fine.

@nlam79
Copy link

nlam79 commented Jun 17, 2016

I think I'm seeing the same thing. So I take a backup and inside the node.json appears to have the correct ipaddress and all of the attributes, but when I do a "knife backup restore nodes", I also see empty attributes on "knife node show ..."

For me, I'm using:
knife-backup (0.0.12)
chef-dk (0.14.25)

@pmoosh
Copy link
Collaborator

pmoosh commented Jun 20, 2016

thx guys - I will look into this when I have a bit more. Currently swamped!!!

@kchristensen
Copy link

Any movement on this issue? I'm attempting to migrate from one Chef server to another and knife-backup isn't restoring any of my node attributes at all as far as I can tell.

@stuartnelson3
Copy link

From looking at the code, it doesn't appear like much data is actually ever repopulated by the method that ends up getting called -- either from_json or from_hash, depending on the version: http://www.rubydoc.info/gems/chef/Chef%2FNode.from_hash

My solution was ... less than ideal.

require 'chef'
require 'chef/knife'

# grab config data from old chef server
Chef::Config.from_file(File.join(Chef::Knife.chef_config_dir, 'knife.rb'))

nodes = Chef::Node.list(true) # takes a while

# switch to new chef config data in knife.rb, client.pem
Chef::Config.from_file(File.join(Chef::Knife.chef_config_dir, 'knife.rb'))
nodes.each { |(name, node)| puts "saving #{name}"; node.save }
# grab a coffee

Not happy-fun-times, but it works.

@chrisgit
Copy link

As the PR was outstanding for sometime and has now been pulled I'd add the following

knife download https://docs.chef.io/knife_download.html
and
knife upload https://docs.chef.io/knife_upload.html
ought to be able to backup and restore a Chef Server.

The above commands use ChefFS http://www.rubydoc.info/gems/chef/Chef/ChefFS which runs much quicker than knife backup which iterates each Chef object and downloads them.

Using knife download It is possible to download the contents of the Chef Server or individual components such as nodes, roles, environments to the filesystem. Cookbooks etc are latest versions.

The contents of the folder created with knife download can then be sent back up to a new Chef Server or restored using knife upload.

If individual items are to be restored you can use knife <node|role|environment> from file <downloaded_file.json>

Examples.
Download all items from Chef Server

knife download / --chef-repo-path "c:/temp/chef/backup"

Downloads just environments

knife download environments --chef-repo-path "c:/temp/chef/backup/environments"

NB: Just make sure your folder structure exists because knife download is not very good at creating folders.

Restore a single node

knife node from file awsome.machine.com.json

Restore all items

knife upload .

Restore just environments

knife upload environments

Finally, if you want to backup a single node you can re-direct the output of knife node show

knife node show <node_name> -l -F json > <node_name>.json

@pmoosh
Copy link
Collaborator

pmoosh commented Jan 23, 2017

Sorry guy - been really busy lately. Main issue at the moment is to test any changes against multiple chef server versions. So when problems are reported or fixes are suggested, note the chef server version as well. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants