itamae-plugin-recipe-idcf-backup_to_object_storage 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e3572ed91e1edb6d8ac8c025236622bcbceb371
4
+ data.tar.gz: 3ea15242134d53f8668f388de221d847a333a8f1
5
+ SHA512:
6
+ metadata.gz: 49d45b3db2fc6c24c7edbcd2c702ce5397fb92e4ad9103713cc538ed3493969cf4f44be4b37fca81aefd3334471f5f04a9ef6a22ad18e86db17de7d8ef995f8d
7
+ data.tar.gz: fde892a7f18dcb9ec6487521539b99359c7859f0edbed2e3d0816f42bdc33cd9377ed6f2d4ccaafc255922363a222b747155a89c22ceab50d17f57239fb2b1e4
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /vendor
12
+ /spec/integration/.vagrant
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in itamae-plugin-recipe-idcf-backup_to_object_storage.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 nownabe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Itamae::Plugin::Recipe::Idcf::BackupToObjectStorage
2
+
3
+ An itamae plugin to backup directories to IDCF Object Storage.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'itamae-plugin-recipe-idcf-backup_to_object_storage'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install itamae-plugin-recipe-idcf-backup_to_object_storage
20
+
21
+ ## Usage
22
+
23
+ ### Configuration
24
+ In you `node.yml` of `node.json`
25
+
26
+ ```yaml
27
+ idcf:
28
+ backup_to_object_storage:
29
+ access_key: YOUR_ACCESS_KEY
30
+ secret_key: YOUR_SECRET_KEY
31
+ directories:
32
+ - schedule: 0 4 * * *
33
+ path: /backup/path1
34
+ bucket: backup.bucket1
35
+ expire: 7 # Default: 7 days
36
+ - schedule: 0 5 * * *
37
+ path: /backup/path2
38
+ bucket: backup.bucket2
39
+ expire: 30
40
+ command: tar zcf /backup/path2/backup_`date +%Y%m%d%H%M`.tar.gz /backup/source
41
+ # This command is executed before backup to object storage
42
+ ```
43
+
44
+ ## Development
45
+
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
47
+
48
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/[my-github-username]/itamae-plugin-recipe-idcf-backup_to_object_storage/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "tempfile"
4
+ require "net/ssh"
5
+
6
+ VAGRANT_HOSTNAME = "ipr-ibtos-spec"
7
+
8
+ desc "Run provisining vagrant and serverspec tests"
9
+ task integration: ["integration:provision", "integration:spec"]
10
+
11
+ namespace :integration do
12
+ desc "Provision Vagrant"
13
+ task :provision do
14
+ env = {"VAGRANT_CWD" => File.expand_path("./spec/integration")}
15
+ tmp_ssh_config = Tempfile.new("", Dir.tmpdir)
16
+
17
+ Bundler.with_clean_env do
18
+ system(env, "vagrant up #{VAGRANT_HOSTNAME}") || abort
19
+ system(env, "vagrant ssh-config #{VAGRANT_HOSTNAME} > #{tmp_ssh_config.path}") || abort
20
+
21
+ ssh_option = Net::SSH::Config.for(VAGRANT_HOSTNAME, [tmp_ssh_config.path])
22
+
23
+ cmd = [
24
+ "bundle exec itamae ssh",
25
+ "-h #{ssh_option[:host_name]}",
26
+ "-u #{ssh_option[:user]}",
27
+ "-p #{ssh_option[:port]}",
28
+ "-i #{ssh_option[:keys].first}",
29
+ "-y spec/integration/node.yml",
30
+ "-l debug",
31
+ "spec/integration/recipe.rb"
32
+ ]
33
+
34
+ cmd << "--dry-run" if ENV["DRY_RUN"]
35
+
36
+ cmd_str = cmd.join(" ")
37
+ puts cmd_str
38
+ system(cmd_str) || abort
39
+ end
40
+ end
41
+
42
+ desc "Run serverspec tests"
43
+ RSpec::Core::RakeTask.new(:spec) do |t|
44
+ ENV["TARGET_HOST"] = VAGRANT_HOSTNAME
45
+ t.ruby_opts = "-I ./spec/integration"
46
+ t.pattern = "spec/integration/*_spec.rb"
47
+ end
48
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itamae/plugin/recipe/idcf/backup_to_object_storage"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'itamae/plugin/recipe/idcf/backup_to_object_storage/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "itamae-plugin-recipe-idcf-backup_to_object_storage"
8
+ spec.version = Itamae::Plugin::Recipe::Idcf::BackupToObjectStorage::VERSION
9
+ spec.authors = ["nownabe"]
10
+ spec.email = ["nownabe@gmail.com"]
11
+
12
+ spec.summary = %q{An itamae plugin to backup directories to IDCF Object Storage}
13
+ spec.homepage = ""
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "itamae"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "serverspec"
25
+ end
@@ -0,0 +1,25 @@
1
+ set -e
2
+
3
+ path=$(echo $1 | sed -re 's#/?$#/#')
4
+ bucket=${2%/}
5
+ expire=$3
6
+ command=$4
7
+
8
+ config="/etc/s3cmd/idcf/backup_to_object_storage.cfg"
9
+
10
+ if [ "$command" != "" ]; then
11
+ : "Execute user command"
12
+ eval $command
13
+ fi
14
+
15
+ : "Make bucket"
16
+ s3cmd -c $config mb s3://$bucket
17
+
18
+ : "Sync backups from object storage"
19
+ s3cmd -c $config sync s3://$bucket/
20
+
21
+ : "Remove expired backups"
22
+ find $path -type f -daystart -mtime +$expire | xargs rm -f
23
+
24
+ : "Sync backups to object storage"
25
+ secmd -c $config sync --delete-removed $path s3://$bucket/
@@ -0,0 +1,11 @@
1
+ package "epel-release"
2
+
3
+ package "s3cmd"
4
+ directory "/etc/s3cmd/idcf"
5
+ template "/etc/s3cmd/idcf/backup_to_object_storage.cfg"
6
+
7
+ directory "/opt/idcf"
8
+ file "/opt/idcf/backup_to_object_storage.sh" do
9
+ mode "0755"
10
+ end
11
+ template "/etc/cron.d/idcf-backup_to_object_storage"
@@ -0,0 +1,11 @@
1
+ module Itamae
2
+ module Plugin
3
+ module Recipe
4
+ module Idcf
5
+ module BackupToObjectStorage
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ <%- node[:idcf][:backup_to_object_storage][:directories].each do |dir| %>
2
+ <%= dir[:schedule] %> <%= dir[:user] || "root" %> /bin/bash /opt/idcf/backup_to_object_storage.sh <%= dir[:path] %> <%= dir[:bucket] %> <%= dir[:expire] %> <%= dir[:command] %>
3
+ <%- end %>
4
+
@@ -0,0 +1,64 @@
1
+ [default]
2
+ access_key = <%= node[:idcf][:backup_to_object_storage][:access_key] %>
3
+ access_token =
4
+ add_encoding_exts =
5
+ add_headers =
6
+ bucket_location = US
7
+ cache_file =
8
+ cloudfront_host = cloudfront.amazonaws.com
9
+ default_mime_type = binary/octet-stream
10
+ delay_updates = False
11
+ delete_after = False
12
+ delete_after_fetch = False
13
+ delete_removed = False
14
+ dry_run = False
15
+ enable_multipart = True
16
+ encoding = UTF-8
17
+ encrypt = False
18
+ expiry_date =
19
+ expiry_days =
20
+ expiry_prefix =
21
+ follow_symlinks = False
22
+ force = False
23
+ get_continue = False
24
+ gpg_command = /usr/bin/gpg
25
+ gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
26
+ gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
27
+ gpg_passphrase =
28
+ guess_mime_type = True
29
+ host_base = ds.jp-east.idcfcloud.com
30
+ host_bucket = %(bucket)s.ds.jp-east.idcfcloud.com
31
+ human_readable_sizes = False
32
+ ignore_failed_copy = False
33
+ invalidate_default_index_on_cf = False
34
+ invalidate_default_index_root_on_cf = True
35
+ invalidate_on_cf = False
36
+ list_md5 = False
37
+ log_target_prefix =
38
+ max_delete = -1
39
+ mime_type =
40
+ multipart_chunk_size_mb = 15
41
+ preserve_attrs = True
42
+ progress_meter = True
43
+ proxy_host =
44
+ proxy_port = 0
45
+ put_continue = False
46
+ recursive = False
47
+ recv_chunk = 4096
48
+ reduced_redundancy = False
49
+ restore_days = 1
50
+ secret_key = <%= node[:idcf][:backup_to_object_storage][:secret_key] %>
51
+ send_chunk = 4096
52
+ server_side_encryption = False
53
+ signature_v2 = True
54
+ simpledb_host = sdb.amazonaws.com
55
+ skip_existing = False
56
+ socket_timeout = 300
57
+ urlencoding_mode = normal
58
+ use_https = False
59
+ use_mime_magic = True
60
+ verbosity = WARNING
61
+ website_endpoint = http://%(bucket)s.s3-website-%(location)s.amazonaws.com/
62
+ website_error =
63
+ website_index = index.html
64
+
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-recipe-idcf-backup_to_object_storage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nownabe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: serverspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - nownabe@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - itamae-plugin-recipe-idcf-backup_to_object_storage.gemspec
86
+ - lib/itamae/plugin/recipe/files/opt/idcf/backup_to_object_storage.sh
87
+ - lib/itamae/plugin/recipe/idcf-backup_to_object_storage.rb
88
+ - lib/itamae/plugin/recipe/idcf/backup_to_object_storage/version.rb
89
+ - lib/itamae/plugin/recipe/templates/etc/cron.d/idcf-backup_to_object_storage.erb
90
+ - lib/itamae/plugin/recipe/templates/etc/s3cmd/idcf/backup_to_object_storage.cfg.erb
91
+ homepage: ''
92
+ licenses: []
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.5
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: An itamae plugin to backup directories to IDCF Object Storage
114
+ test_files: []