Commit b8a7ea9e59bb661876a5f7d9637d6595aadcb6ae

Authored by Earth Ugat
1 parent d006aa8f

Version v0.4.0

  1 +## 0.4.0 - 2016-12-13
  2 +### Added
  3 +- AWS bucket and region can now be specified per element of the attribute `node['backup-file2s3']['backups']`. If not specified, bucket and region will default to the global node attributes `node['backup-file2s3']['bucket']` and `node['backup-file2s3']['region']`, respectively.
  4 +
  5 +### Fixed
  6 +- Fixed a logic bug when trying to determine if at least one enabled path specification is encrypted or not.
  7 +
1 ## 0.3.3 - 2016-11-29 8 ## 0.3.3 - 2016-11-29
2 ### Fixed 9 ### Fixed
3 - A typo in the backup script (missing end quotes). 10 - A typo in the backup script (missing end quotes).
@@ -22,14 +22,14 @@ Ubuntu 14.04 @@ -22,14 +22,14 @@ Ubuntu 14.04
22 <tr> 22 <tr>
23 <td><tt>['backup-file2s3']['bucket']</tt></td> 23 <td><tt>['backup-file2s3']['bucket']</tt></td>
24 <td>String</td> 24 <td>String</td>
25 - <td>The S3 bucket where backup tarballs will be stored.</td> 25 + <td>The default S3 bucket where backup tarballs will be stored.</td>
26 <td><tt>nil</tt></td> 26 <td><tt>nil</tt></td>
27 </tr> 27 </tr>
28 <tr> 28 <tr>
29 <td><tt>['backup-file2s3']['region']</tt></td> 29 <td><tt>['backup-file2s3']['region']</tt></td>
30 <td>String</td> 30 <td>String</td>
31 - <td>AWS region of the bucket.</td>  
32 - <td><tt>'us-east-1'</tt></td> 31 + <td>Default AWS region.</td>
  32 + <td><tt>nil</tt></td>
33 </tr> 33 </tr>
34 <tr> 34 <tr>
35 <td><tt>['backup-file2s3']['backups']</tt></td> 35 <td><tt>['backup-file2s3']['backups']</tt></td>
@@ -40,7 +40,7 @@ Ubuntu 14.04 @@ -40,7 +40,7 @@ Ubuntu 14.04
40 <tr> 40 <tr>
41 <td><tt>['backup-file2s3']['cron']['sched']</tt></td> 41 <td><tt>['backup-file2s3']['cron']['sched']</tt></td>
42 <td>String</td> 42 <td>String</td>
43 - <td>Crontab syntax for scheduling how often the backup script will run.</td> 43 + <td>Crontab syntax for scheduling how often the backup script/s will run.</td>
44 <td><tt>'0 0 * * *'</tt></td> 44 <td><tt>'0 0 * * *'</tt></td>
45 </tr> 45 </tr>
46 <tr> 46 <tr>
@@ -18,8 +18,10 @@ @@ -18,8 +18,10 @@
18 # limitations under the License. 18 # limitations under the License.
19 # 19 #
20 20
21 -default['backup-file2s3']['bucket'] = 'bucketname'  
22 -default['backup-file2s3']['region'] = 'us-east-1' 21 +# Defaults if bucket and region are not included in the specifications
  22 +# for 'backups' or when using the 'aws_tar_extract' definition.
  23 +default['backup-file2s3']['bucket'] = nil
  24 +default['backup-file2s3']['region'] = nil
23 25
24 # Contains hashes with details of file/directories to be backed up to S3. 26 # Contains hashes with details of file/directories to be backed up to S3.
25 default['backup-file2s3']['backups'] = [ 27 default['backup-file2s3']['backups'] = [
@@ -27,6 +29,8 @@ default['backup-file2s3']['backups'] = [ @@ -27,6 +29,8 @@ default['backup-file2s3']['backups'] = [
27 # :script_name => 'default', # default: 'default', but only 29 # :script_name => 'default', # default: 'default', but only
28 # # one default can exist at a time 30 # # one default can exist at a time
29 # :enable => true # default: true 31 # :enable => true # default: true
  32 +# :bucket => nil, # default: node attribute
  33 +# :region => nil, # default: node attribute
30 # :paths => [ 34 # :paths => [
31 # { 35 # {
32 # :path => '/my/dir', 36 # :path => '/my/dir',
@@ -21,11 +21,11 @@ @@ -21,11 +21,11 @@
21 # Gets a tarball from AWS S3, then unpack it into a directory. 21 # Gets a tarball from AWS S3, then unpack it into a directory.
22 # Parameters: 22 # Parameters:
23 # :name | :file => The name of the backup tarball, without the extension 23 # :name | :file => The name of the backup tarball, without the extension
24 -# :region => AWS region  
25 -# :bucket => AWS bucket  
26 # :target_dir => Where the tarball is to be unpacked. If not 24 # :target_dir => Where the tarball is to be unpacked. If not
27 # exists, it will be created 25 # exists, it will be created
28 # :creates => A file path used for idempotency 26 # :creates => A file path used for idempotency
  27 +# :region => (Optional) AWS region. Defaults to node attribute.
  28 +# :bucket => (Optional) AWS bucket. Defaults to node attribute.
29 # :encrypted => (Optional) Boolean. Whether backup files are encrypted. 29 # :encrypted => (Optional) Boolean. Whether backup files are encrypted.
30 # :priv_key => (Optional) String. Contents of private key, if used. 30 # :priv_key => (Optional) String. Contents of private key, if used.
31 31
@@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com' @@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com'
4 license 'Apache License' 4 license 'Apache License'
5 description 'Creates a script to backup directories into an S3 bucket.' 5 description 'Creates a script to backup directories into an S3 bucket.'
6 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7 -version '0.3.3' 7 +version '0.4.0'
8 8
9 depends 'awscli', '~> 1.0.1' 9 depends 'awscli', '~> 1.0.1'
10 depends 'cron', '~> 1.7.4' 10 depends 'cron', '~> 1.7.4'
@@ -28,8 +28,13 @@ directory attribs['script_dir'] { recursive true } @@ -28,8 +28,13 @@ directory attribs['script_dir'] { recursive true }
28 directory attribs['log_dir'] { recursive true } 28 directory attribs['log_dir'] { recursive true }
29 29
30 is_any_enc = attribs['backups'].any? do |back| 30 is_any_enc = attribs['backups'].any? do |back|
31 - back[:paths].any? do |path|  
32 - path[:bak_encrypted] 31 + enable = back.has_key?(:enable) ? back[:enable] : true
  32 + if enable
  33 + back[:paths].any? do |path|
  34 + path[:bak_encrypted]
  35 + end
  36 + else
  37 + false
33 end 38 end
34 end 39 end
35 if !attribs['encrypt']['pub_key'] && is_any_enc 40 if !attribs['encrypt']['pub_key'] && is_any_enc
@@ -37,12 +42,12 @@ if !attribs['encrypt']['pub_key'] && is_any_enc @@ -37,12 +42,12 @@ if !attribs['encrypt']['pub_key'] && is_any_enc
37 end 42 end
38 43
39 file pub_key_file do 44 file pub_key_file do
40 - content attribs['encrypt']['pub_key'] 45 + content attribs['encrypt']['pub_key']
41 mode 0600 46 mode 0600
42 owner 'root' 47 owner 'root'
43 group 'root' 48 group 'root'
44 sensitive true 49 sensitive true
45 - only_if { attribs['encrypt']['pub_key'] } 50 + only_if { is_any_enc }
46 end 51 end
47 52
48 attribs['backups'].each do |back| 53 attribs['backups'].each do |back|
@@ -57,8 +62,8 @@ attribs['backups'].each do |back| @@ -57,8 +62,8 @@ attribs['backups'].each do |back|
57 :aws_bin => attribs['aws_bin'], 62 :aws_bin => attribs['aws_bin'],
58 :tar_bin => attribs['tar_bin'], 63 :tar_bin => attribs['tar_bin'],
59 :tmp_dir => attribs['tmp_dir'], 64 :tmp_dir => attribs['tmp_dir'],
60 - :bucket => attribs['bucket'],  
61 - :region => attribs['region'], 65 + :bucket => back[:bucket] || attribs['bucket'],
  66 + :region => back[:region] || attribs['region'],
62 :pub_key_file => pub_key_file, 67 :pub_key_file => pub_key_file,
63 :paths => back[:paths] 68 :paths => back[:paths]
64 ) 69 )
@@ -18,7 +18,7 @@ region=<%= @region %> @@ -18,7 +18,7 @@ region=<%= @region %>
18 bak_dir=<%= @tmp_dir %> 18 bak_dir=<%= @tmp_dir %>
19 19
20 aws_bin=<%= @aws_bin %> 20 aws_bin=<%= @aws_bin %>
21 -tar_bin=<%= @tar_bin || '/bin/tar' %> 21 +tar_bin=<%= @tar_bin %>
22 22
23 pub_key_file=<%= @pub_key_file %> 23 pub_key_file=<%= @pub_key_file %>
24 24