sink3 0.0.3 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/sink3.rb +4 -0
- data/lib/sink3/main.rb +26 -9
- data/lib/sink3/path_crawler.rb +24 -3
- data/lib/sink3/version.rb +1 -1
- metadata +17 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bf1b237eda4a1a43f23fbba25471c652201aa05392bc1e292812585f7a3fc5e2
|
4
|
+
data.tar.gz: e689696ad585165583c2c56a17d653071bec6f6b363b13db0d006f8908cd2e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf2ddf9eb3b8a056d2acf22481a64ef0e045579ad705ea219c4102b62f9a93a3b30f229776e85f662d715657b284f9361f1d7db4fd2ac8938247e9b0fd9a04a
|
7
|
+
data.tar.gz: 5052a3ad6ed84f10ba6a241cf506d0a7daa04ffc0a166710b2ea6db774becdc557d2ef4a8dd98c80512387499394defd18c1d0f906130bf46d23b5fc0767c240
|
data/lib/sink3.rb
CHANGED
@@ -15,6 +15,10 @@ module Sink3
|
|
15
15
|
|
16
16
|
class Configuration
|
17
17
|
attr_accessor :delete_after_upload
|
18
|
+
attr_accessor :skip_overwrite
|
19
|
+
attr_accessor :skip_date_partition
|
20
|
+
attr_accessor :verbose
|
21
|
+
attr_accessor :skip_full_path
|
18
22
|
|
19
23
|
def delete_after_upload
|
20
24
|
!!@delete_after_upload
|
data/lib/sink3/main.rb
CHANGED
@@ -9,22 +9,35 @@ require 'sink3/path_crawler'
|
|
9
9
|
|
10
10
|
module Sink3
|
11
11
|
class Main < Thor
|
12
|
-
|
13
|
-
|
12
|
+
#
|
14
13
|
# option :path, :required => true
|
15
|
-
desc "
|
14
|
+
desc "send", "Send files to S3 in write only mode"
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
option :delete, type: :boolean, desc: "delete origin file on succesful send"
|
17
|
+
option :skip_overwrite, type: :boolean, desc: "skip sending file if exists"
|
18
|
+
option :verbose, type: :boolean, desc: "verbose"
|
19
|
+
option :skip_date_partition, type: :boolean, desc: "remove YYYY-MM-DD remote prefix"
|
20
|
+
option :skip_full_path, type: :boolean, desc: "don't archive file with full path prefix"
|
21
21
|
|
22
|
+
def send(*paths)
|
23
|
+
configure
|
22
24
|
# overwrite hostname if configured
|
23
25
|
Dotenv.overload('~/.sink3cfg')
|
26
|
+
|
24
27
|
validate_env
|
25
28
|
|
26
|
-
prefix =
|
27
|
-
|
29
|
+
prefix = nil
|
30
|
+
[paths].flatten.each do |path|
|
31
|
+
path = Pathname.new(path)
|
32
|
+
raise "specified path does not exist" unless path.exist?
|
33
|
+
|
34
|
+
if path.relative? || Sink3.config.skip_full_path
|
35
|
+
prefix = nil
|
36
|
+
else
|
37
|
+
path = path.realdirpath
|
38
|
+
end
|
39
|
+
Sink3::PathCrawler.new(path, prefix).start
|
40
|
+
end
|
28
41
|
end
|
29
42
|
|
30
43
|
private
|
@@ -34,6 +47,10 @@ module Sink3
|
|
34
47
|
|
35
48
|
Sink3.configure do |config|
|
36
49
|
config.delete_after_upload = options[:delete]
|
50
|
+
config.skip_overwrite = options[:skip_overwrite]
|
51
|
+
config.verbose = options[:verbose]
|
52
|
+
config.skip_date_partition = options[:skip_date_partition]
|
53
|
+
config.skip_full_path = options[:skip_full_path]
|
37
54
|
end
|
38
55
|
end
|
39
56
|
|
data/lib/sink3/path_crawler.rb
CHANGED
@@ -44,10 +44,27 @@ module Sink3
|
|
44
44
|
s3.buckets[ENV['BUCKET']]
|
45
45
|
end
|
46
46
|
|
47
|
+
def check_exists remote_file
|
48
|
+
remote_file.exists?
|
49
|
+
rescue AWS::S3::Errors::Forbidden
|
50
|
+
# expect this error to be returned when file exists
|
51
|
+
# and we don't have access to read the file
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
47
55
|
def send_to_remote
|
48
|
-
remote_path = "#{ENV['HOSTNAME'].strip}/#{formatted_date}
|
56
|
+
remote_path = "#{ENV['HOSTNAME'].strip}/#{formatted_date}#{prefix_and_path}"
|
49
57
|
remote_file = bucket.objects[remote_path]
|
50
|
-
|
58
|
+
if Sink3.config.skip_overwrite
|
59
|
+
if ! check_exists(remote_file)
|
60
|
+
puts "remote file does not exist #{remote_path}" if Sink3.config.verbose
|
61
|
+
remote_file.write(@path)
|
62
|
+
else
|
63
|
+
puts "skpping overwrite of #{remote_path}" if Sink3.config.verbose
|
64
|
+
end
|
65
|
+
else
|
66
|
+
remote_file.write(@path)
|
67
|
+
end
|
51
68
|
|
52
69
|
if Sink3.config.delete_after_upload?
|
53
70
|
FileUtils.rm @path
|
@@ -55,7 +72,11 @@ module Sink3
|
|
55
72
|
end
|
56
73
|
|
57
74
|
def formatted_date
|
58
|
-
|
75
|
+
if !Sink3.config.skip_date_partition
|
76
|
+
return "#{Time.now.strftime "%Y-%m-%d"}/"
|
77
|
+
else
|
78
|
+
return ""
|
79
|
+
end
|
59
80
|
end
|
60
81
|
|
61
82
|
def prefix_and_path
|
data/lib/sink3/version.rb
CHANGED
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sink3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabrizio Regini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.61.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.61.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dotenv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.11.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.11.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.19.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.19.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.5'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Sink3 is an S3 backup designed to work with write-only keys.
|
@@ -88,8 +88,8 @@ executables:
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- .gitignore
|
92
|
-
- .rspec
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
@@ -116,17 +116,16 @@ require_paths:
|
|
116
116
|
- lib
|
117
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
|
-
- -
|
119
|
+
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
|
129
|
-
rubygems_version: 2.2.1
|
128
|
+
rubygems_version: 3.0.8
|
130
129
|
signing_key:
|
131
130
|
specification_version: 4
|
132
131
|
summary: S3 backup designed for servers
|