glacier-cli 0.0.2
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/glacier +13 -0
- data/glacier-cli.gemspec +26 -0
- data/lib/glacier/cli.rb +101 -0
- data/lib/glacier/cli/version.rb +5 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c423f2cd567d44ae78cb78004a48761fd52da47e
|
4
|
+
data.tar.gz: 418b0c519eb1272500929ec0af75b136fdcad782
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a5a2fcaf1ce19b7934f90c4f01e568fdd9c4fd1bd7c18142caf93bb5d426cc488733e7c1ca2bc439cf489083a227f6bcc8ba41bf549e484ce9c0e0ee002c7cd
|
7
|
+
data.tar.gz: d03763d95b1ac7f7f31978fa2adde87600010acd1fea14b43684829e51f609d6c79720523f245dd6eb5bf0fa0fcdbc7686501aeb76c89af9a4c50c59a823f205
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Cade Truitt
|
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,31 @@
|
|
1
|
+
# Glacier::CLI
|
2
|
+
|
3
|
+
Basic CLI for AWS Glacier to back up files.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'glacier-cli'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install glacier-cli
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/cade/glacier-cli/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/glacier
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/glacier/cli'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Glacier::CLI.new(ARGV).run
|
7
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
8
|
+
puts e.message
|
9
|
+
abort "usage: #{`glacier -h`}"
|
10
|
+
rescue => e
|
11
|
+
puts e.message
|
12
|
+
abort e.backtrace.join("\n")
|
13
|
+
end
|
data/glacier-cli.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'glacier/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "glacier-cli"
|
8
|
+
spec.version = Glacier::CLI::VERSION
|
9
|
+
spec.authors = ["Cade Truitt"]
|
10
|
+
spec.email = ["cadetruitt@gmail.com"]
|
11
|
+
spec.summary = %q{Basic CLI for AWS Glacier to back up files.}
|
12
|
+
spec.description = %q{The hopefully simple way to get all those video files off of your wife's laptop.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
|
25
|
+
spec.add_dependency 'fog', '~> 1.27.0'
|
26
|
+
end
|
data/lib/glacier/cli.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'fog'
|
3
|
+
require 'find'
|
4
|
+
require 'set'
|
5
|
+
require_relative "./cli/version"
|
6
|
+
|
7
|
+
module Glacier
|
8
|
+
def self.env
|
9
|
+
ENV['GLACIER_CLI_ENV'] || 'development'
|
10
|
+
end
|
11
|
+
|
12
|
+
class CLI
|
13
|
+
CHUNK_SIZE = 1024 * 1024 * 8 # 8 MB
|
14
|
+
LOCAL_STORE = "#{ENV['HOME']}/.glacier"
|
15
|
+
|
16
|
+
def initialize(args)
|
17
|
+
@files = []
|
18
|
+
@directories = []
|
19
|
+
parse_options args
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
@directories.each do |directory|
|
24
|
+
Find.find(directory == '.' ? Dir.pwd : directory) do |path|
|
25
|
+
dot = File.basename(path).start_with? '.'
|
26
|
+
if FileTest.directory? path
|
27
|
+
# completely skip 'dot' directories
|
28
|
+
Find.prune if dot
|
29
|
+
else
|
30
|
+
# ignore dotfiles
|
31
|
+
@files << path unless dot
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
@files.each do |file|
|
37
|
+
basename = File.basename(file)
|
38
|
+
if uploaded_files.include? basename
|
39
|
+
puts "Skipping #{file} (already uploaded)"
|
40
|
+
else
|
41
|
+
vault.archives.create body: File.new(file), multipart_chunk_size: CHUNK_SIZE, description: basename
|
42
|
+
File.write LOCAL_STORE, "#{basename}\n", mode: 'a'
|
43
|
+
puts "Uploaded #{file}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def vault
|
51
|
+
@vault ||= backend.vaults.get @vault_name
|
52
|
+
end
|
53
|
+
|
54
|
+
def backend
|
55
|
+
@backend ||= Fog::AWS::Glacier.new(
|
56
|
+
region: ENV['AWS_REGION'],
|
57
|
+
aws_access_key_id: ENV['AWS_ACCESS_KEY'],
|
58
|
+
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def uploaded_files
|
63
|
+
FileTest.exist?(LOCAL_STORE) ? File.read(LOCAL_STORE).split("\n").to_set : []
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_options(args)
|
67
|
+
parser = OptionParser.new do |o|
|
68
|
+
o.banner = 'glacier [options]'
|
69
|
+
|
70
|
+
o.on '-v', '--vault VAULT_NAME', 'Name of vault to store archives in' do |arg|
|
71
|
+
@vault_name = arg
|
72
|
+
end
|
73
|
+
|
74
|
+
o.on '-f', '--file [FILE_NAME]', 'Name of file to store' do |arg|
|
75
|
+
@files << arg
|
76
|
+
end
|
77
|
+
|
78
|
+
o.on '-d', '--directory [DIRECTORY_NAME]', 'Name of file to store' do |arg|
|
79
|
+
@directories << arg
|
80
|
+
end
|
81
|
+
|
82
|
+
o.on_tail '-h', '--help', 'Show help' do
|
83
|
+
puts o
|
84
|
+
exit
|
85
|
+
end
|
86
|
+
|
87
|
+
o.on_tail '-v', '--version', 'Show version' do
|
88
|
+
puts "Glacier::CLI #{Glacier::CLI::VERSION}"
|
89
|
+
exit
|
90
|
+
end
|
91
|
+
end
|
92
|
+
parser.parse! args
|
93
|
+
|
94
|
+
unless @vault_name && (@files || @directories)
|
95
|
+
puts 'Must specify vault via -v argument' unless @vault_name && vault
|
96
|
+
puts 'Must specify file or directory via -f or -d argument' unless @files || @directories
|
97
|
+
exit false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glacier-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cade Truitt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fog
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.27.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.27.0
|
69
|
+
description: The hopefully simple way to get all those video files off of your wife's
|
70
|
+
laptop.
|
71
|
+
email:
|
72
|
+
- cadetruitt@gmail.com
|
73
|
+
executables:
|
74
|
+
- glacier
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/glacier
|
84
|
+
- glacier-cli.gemspec
|
85
|
+
- lib/glacier/cli.rb
|
86
|
+
- lib/glacier/cli/version.rb
|
87
|
+
homepage: ''
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Basic CLI for AWS Glacier to back up files.
|
111
|
+
test_files: []
|