knife-backup 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36390e9342000ad1b041f6ce2070558bff7abccb
4
- data.tar.gz: 0056c9f916c433aeb1f22522d833ab853fbf7f97
3
+ metadata.gz: 918be2fa6d1491b4927ecf0da398fbe091996932
4
+ data.tar.gz: d5020e9bee1536d0972bcaa54237705d4d352c72
5
5
  SHA512:
6
- metadata.gz: 2c2b968a7742955e20f09609964be820a796db2bfda9753dca9b68d1b897449389b5568c753f00134e2a0771762ec5749a7b1e108679dec604ea8041174cff19
7
- data.tar.gz: 02951b27f37b7a24aa1a3a0723fae58dda4bb393c2b0110e29a26653b5b01293dde45a99590d18a931a5d9ad92d0eda705ad43faad4049d0aadb1f2c13b901e5
6
+ metadata.gz: 85dad02bd0ec4235da0f74814a1397083aaca2c63647862c7c1610e77908208e52998c5694d9488b9ae5b55c709a52565805833b9786c3f65d19f4ab10d19474
7
+ data.tar.gz: f15c5518f7844177800a3dc27b0c7e377ec06df850a969da78391dce7b4d557f3077294b456ddd483283020b0af45ae06901f7596737ca56150dc78d523db148
data/README.md CHANGED
@@ -15,7 +15,7 @@ knife-backup will backup all cookbook versions available on the chef server. Coo
15
15
 
16
16
  Users are a bit tricky, knife-backup can't gather the crypted passwords via the chef server so it's forced to reset them to a random string on restore. Be sure to copy them from the restore output or reset them.
17
17
 
18
- *Known limitation*: currently it is not possible to overwritte a client object already available on the target server and these will be skipped.
18
+ *Known limitation*: currently it is not possible to overwrite a client object already available on the target server and these will be skipped.
19
19
 
20
20
  ## Installation
21
21
 
@@ -27,26 +27,30 @@ gem install knife-backup
27
27
 
28
28
  ## Usage
29
29
 
30
- For a list of commands:
31
-
32
- ```bash
33
- knife backup --help
34
- ```
35
-
36
30
  Currently the available commands are:
37
31
 
38
32
  ```bash
39
- knife backup export [component component ...] [-D DIR]
33
+ knife backup export [component component ...] [-D DIR] [options]
40
34
  knife backup restore [component component ...] [-D DIR]
41
35
 
42
36
  #Example:
43
37
  knife backup export cookbooks roles environments -D ~/my_chef_backup
44
38
  ```
39
+ #### Optional Switches for export
40
+
41
+ - `-N`, `--latest` only download the latest version of a cookbook
42
+ - `-I`, `--ignore-permissions` ignore any permission errors during export
43
+
44
+ For more information on commands:
45
+
46
+ ```bash
47
+ knife backup SUB-COMMAND --help
48
+ ```
45
49
 
46
50
  Note: you should treat this as beta software; I'm using it with success for my needs and hopefully you will find it useful too.
47
51
 
48
52
  ## Todo/Ideas
49
-
53
+
50
54
  * Timestamp for the backup folder
51
55
  * Track the failed downloads and report them at the end
52
56
  * Find out if there is a way to overwrite a client object.
@@ -46,6 +46,12 @@ module ServerBackup
46
46
  :description => "The version of the cookbook to download",
47
47
  :boolean => true
48
48
 
49
+ option :ignore_perm,
50
+ :short => "-I",
51
+ :long => "--ignore-permissions",
52
+ :description => "Continue in case a permission problem occurs",
53
+ :boolean => true
54
+
49
55
  def run
50
56
  validate!
51
57
  components = name_args.empty? ? COMPONENTS : name_args
@@ -72,7 +78,7 @@ module ServerBackup
72
78
  backup_standard("clients", Chef::ApiClient)
73
79
  end
74
80
 
75
- def users
81
+ def users
76
82
  if Chef::VERSION =~ /^1[1-9]\./
77
83
  backup_standard("users", Chef::User)
78
84
  else
@@ -130,6 +136,13 @@ module ServerBackup
130
136
  try += 1
131
137
  load_object(klass, name, try)
132
138
  end
139
+ rescue Net::HTTPServerException => e
140
+ if config[:ignore_perm]
141
+ ui.warn "Problem loading #{name} #{e.message}."
142
+ ui.warn "Possibly an issue with permissions on the chef server... Skipping"
143
+ else
144
+ raise
145
+ end
133
146
  end
134
147
 
135
148
  def cookbooks
@@ -47,7 +47,7 @@ module ServerBackup
47
47
  def run
48
48
  ui.warn "This will overwrite existing data!"
49
49
  ui.warn "Backup is at least 1 day old" if (Time.now - File.atime(config[:backup_dir])) > 86400
50
- ui.confirm "Do you want to restore backup, possibly overwriting exisitng data"
50
+ ui.confirm "Do you want to restore backup, possibly overwriting existing data"
51
51
  validate!
52
52
  components = name_args.empty? ? COMPONENTS : name_args
53
53
  Array(components).each { |component| self.send(component) }
@@ -123,7 +123,8 @@ module ServerBackup
123
123
  rest.post_rest("clients", {
124
124
  :name => client['name'],
125
125
  :public_key => client['public_key'],
126
- :admin => client['admin']
126
+ :admin => client['admin'],
127
+ :validator => client['validator']
127
128
  })
128
129
  rescue Net::HTTPServerException => e
129
130
  handle_error 'client', client['name'], e
@@ -159,12 +160,14 @@ module ServerBackup
159
160
  def cookbooks
160
161
  ui.info "=== Restoring cookbooks ==="
161
162
  cookbooks = Dir.glob(File.join(config[:backup_dir], "cookbooks", '*'))
162
- cookbooks.each do |cb|
163
+ #Make tmp dir
164
+ cookbooks.each do |cb|
165
+ FileUtils.rm_rf(config[:backup_dir] + "/tmp")
166
+ Dir.mkdir config[:backup_dir] + "/tmp"
163
167
  full_cb = File.expand_path(cb)
164
168
  cb_name = File.basename(cb)
165
169
  cookbook = cb_name.reverse.split('-',2).last.reverse
166
- full_path = File.join(File.dirname(full_cb), cookbook)
167
-
170
+ full_path = File.join(config[:backup_dir] + "/tmp", cookbook)
168
171
  begin
169
172
  File.symlink(full_cb, full_path)
170
173
  cbu = Chef::Knife::CookbookUpload.new
@@ -178,6 +181,7 @@ module ServerBackup
178
181
  ensure
179
182
  File.unlink(full_path)
180
183
  end
184
+ FileUtils.rm_rf(config[:backup_dir] + "/tmp")
181
185
  end
182
186
  end
183
187
 
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Backup
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marius Ducea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -61,8 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project: knife-backup
64
- rubygems_version: 2.2.2
64
+ rubygems_version: 2.4.4
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Chef knife plugins to help backup and restore chef servers
68
68
  test_files: []
69
+ has_rdoc: