Showing
7 changed files
with
32 additions
and
16 deletions
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 | 8 | ## 0.3.3 - 2016-11-29 |
2 | 9 | ### Fixed |
3 | 10 | - A typo in the backup script (missing end quotes). | ... | ... |
... | ... | @@ -22,14 +22,14 @@ Ubuntu 14.04 |
22 | 22 | <tr> |
23 | 23 | <td><tt>['backup-file2s3']['bucket']</tt></td> |
24 | 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 | 26 | <td><tt>nil</tt></td> |
27 | 27 | </tr> |
28 | 28 | <tr> |
29 | 29 | <td><tt>['backup-file2s3']['region']</tt></td> |
30 | 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 | 33 | </tr> |
34 | 34 | <tr> |
35 | 35 | <td><tt>['backup-file2s3']['backups']</tt></td> |
... | ... | @@ -40,7 +40,7 @@ Ubuntu 14.04 |
40 | 40 | <tr> |
41 | 41 | <td><tt>['backup-file2s3']['cron']['sched']</tt></td> |
42 | 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 | 44 | <td><tt>'0 0 * * *'</tt></td> |
45 | 45 | </tr> |
46 | 46 | <tr> | ... | ... |
... | ... | @@ -18,8 +18,10 @@ |
18 | 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 | 26 | # Contains hashes with details of file/directories to be backed up to S3. |
25 | 27 | default['backup-file2s3']['backups'] = [ |
... | ... | @@ -27,6 +29,8 @@ default['backup-file2s3']['backups'] = [ |
27 | 29 | # :script_name => 'default', # default: 'default', but only |
28 | 30 | # # one default can exist at a time |
29 | 31 | # :enable => true # default: true |
32 | +# :bucket => nil, # default: node attribute | |
33 | +# :region => nil, # default: node attribute | |
30 | 34 | # :paths => [ |
31 | 35 | # { |
32 | 36 | # :path => '/my/dir', | ... | ... |
... | ... | @@ -21,11 +21,11 @@ |
21 | 21 | # Gets a tarball from AWS S3, then unpack it into a directory. |
22 | 22 | # Parameters: |
23 | 23 | # :name | :file => The name of the backup tarball, without the extension |
24 | -# :region => AWS region | |
25 | -# :bucket => AWS bucket | |
26 | 24 | # :target_dir => Where the tarball is to be unpacked. If not |
27 | 25 | # exists, it will be created |
28 | 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 | 29 | # :encrypted => (Optional) Boolean. Whether backup files are encrypted. |
30 | 30 | # :priv_key => (Optional) String. Contents of private key, if used. |
31 | 31 | ... | ... |
... | ... | @@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com' |
4 | 4 | license 'Apache License' |
5 | 5 | description 'Creates a script to backup directories into an S3 bucket.' |
6 | 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 | 9 | depends 'awscli', '~> 1.0.1' |
10 | 10 | depends 'cron', '~> 1.7.4' | ... | ... |
... | ... | @@ -28,8 +28,13 @@ directory attribs['script_dir'] { recursive true } |
28 | 28 | directory attribs['log_dir'] { recursive true } |
29 | 29 | |
30 | 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 | 38 | end |
34 | 39 | end |
35 | 40 | if !attribs['encrypt']['pub_key'] && is_any_enc |
... | ... | @@ -37,12 +42,12 @@ if !attribs['encrypt']['pub_key'] && is_any_enc |
37 | 42 | end |
38 | 43 | |
39 | 44 | file pub_key_file do |
40 | - content attribs['encrypt']['pub_key'] | |
45 | + content attribs['encrypt']['pub_key'] | |
41 | 46 | mode 0600 |
42 | 47 | owner 'root' |
43 | 48 | group 'root' |
44 | 49 | sensitive true |
45 | - only_if { attribs['encrypt']['pub_key'] } | |
50 | + only_if { is_any_enc } | |
46 | 51 | end |
47 | 52 | |
48 | 53 | attribs['backups'].each do |back| |
... | ... | @@ -57,8 +62,8 @@ attribs['backups'].each do |back| |
57 | 62 | :aws_bin => attribs['aws_bin'], |
58 | 63 | :tar_bin => attribs['tar_bin'], |
59 | 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 | 67 | :pub_key_file => pub_key_file, |
63 | 68 | :paths => back[:paths] |
64 | 69 | ) | ... | ... |