s3-migrator 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/bin/s3-migrator +1 -0
- data/lib/s3/migrator.rb +12 -3
- data/lib/s3/migrator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 844d9650749c205ec33b36c015fc8835b36c694f
|
4
|
+
data.tar.gz: fbb246acccfc815c767879bb2f753cece84793db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec06f456c4579def35c3a08ea72a4c1238fa49406959056a6ac58d14691762f6033d13a12ffad8b868d011c8a60033b4747a7fa1f03ebcb6b2071c097b76cbe
|
7
|
+
data.tar.gz: 047d37d21d4564444246b33a053cdbe21bd87baf28afa757c7bd14199e29987e98101e53c3f5f7d3265933e3f86c7282bccd0ce9290c46dc2c624d5f26ef1ebb
|
data/.gitignore
CHANGED
data/bin/s3-migrator
CHANGED
@@ -10,6 +10,7 @@ OptionParser.new { |o|
|
|
10
10
|
o.on("-s", "--src-bucket SOURCE_BUCKET") { |v| opts[:src_bucket] = v }
|
11
11
|
o.on("-d", "--dest-bucket DESTINATION_BUCKET", ) { |v| opts[:dest_bucket] = v }
|
12
12
|
o.on("-p", "--prefix [PREFIX]") { |v| opts[:prefix] = v }
|
13
|
+
o.on("--profile [AWS PROFILE]") { |v| opts[:profile] = v }
|
13
14
|
o.on("-t", "--thread [COUNT]") { |v| opts[:thread_count] = v }
|
14
15
|
}.parse!(ARGV)
|
15
16
|
|
data/lib/s3/migrator.rb
CHANGED
@@ -13,8 +13,17 @@ module S3
|
|
13
13
|
DEFAULT_THREAD_COUNT = 10
|
14
14
|
|
15
15
|
def migrate!(opts)
|
16
|
-
|
17
|
-
|
16
|
+
# use ~/.aws/credentials if without credentials opts
|
17
|
+
creds = if opts[:profile]
|
18
|
+
Aws::SharedCredentials.new(profile_name: opts[:profile])
|
19
|
+
elsif opts[:access_key_id] && opts[:secret_access_key]
|
20
|
+
Aws::Credentials.new(opts[:access_key_id], opts[:secret_access_key])
|
21
|
+
end
|
22
|
+
|
23
|
+
client_opts = { region: opts[:region] || ENV['AWS_REGION'] }
|
24
|
+
client_opts[:credentials] = creds if creds
|
25
|
+
|
26
|
+
s3_client = Aws::S3::Client.new(client_opts)
|
18
27
|
|
19
28
|
pagerble = if opts[:prefix]
|
20
29
|
s3_client.list_objects(bucket: opts[:src_bucket], prefix: opts[:prefix])
|
@@ -25,7 +34,7 @@ module S3
|
|
25
34
|
logger = Logger.new(STDOUT)
|
26
35
|
|
27
36
|
begin
|
28
|
-
each_in_threads(opts[:thread_count] || DEFAULT_THREAD_COUNT, pagerble.contents) do |obj|
|
37
|
+
each_in_threads(opts[:thread_count].to_i || DEFAULT_THREAD_COUNT, pagerble.contents) do |obj|
|
29
38
|
begin
|
30
39
|
s3_client.copy_object(
|
31
40
|
bucket: opts[:dest_bucket],
|
data/lib/s3/migrator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3-migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoppi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.5.1
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: '"Migrate S3 object"'
|