s3backup 0.6.3 → 0.6.4
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.
- data/lib/s3backup/manager.rb +17 -4
- data/lib/s3backup/s3wrapper.rb +14 -1
- data/lib/s3backup.rb +1 -1
- metadata +23 -3
data/lib/s3backup/manager.rb
CHANGED
|
@@ -6,7 +6,19 @@ require 's3backup/tree_info'
|
|
|
6
6
|
require 's3backup/crypt'
|
|
7
7
|
module S3backup
|
|
8
8
|
class Manager
|
|
9
|
-
DEFAULT_BUF_READ_SIZE=1024*1024*
|
|
9
|
+
DEFAULT_BUF_READ_SIZE=1024*1024*64
|
|
10
|
+
def shell_name(str)
|
|
11
|
+
str.gsub!(/[!"$&'()*,:;<=>?\[\]^`{|}\s]/, '\\\\\&')
|
|
12
|
+
a=[]
|
|
13
|
+
str.each_byte{|i|
|
|
14
|
+
if i < 0x80
|
|
15
|
+
a.push(sprintf("%c",i))
|
|
16
|
+
else
|
|
17
|
+
a.push("'"+sprintf("%c",i) + "'")
|
|
18
|
+
end
|
|
19
|
+
}
|
|
20
|
+
return a.join;
|
|
21
|
+
end
|
|
10
22
|
def initialize(target,config)
|
|
11
23
|
@target = target
|
|
12
24
|
set_config(config)
|
|
@@ -39,8 +51,9 @@ module S3backup
|
|
|
39
51
|
sub_dir.push(file) if File.directory?(dir+"/"+file)
|
|
40
52
|
end
|
|
41
53
|
exclude = ""
|
|
42
|
-
exclude = exclude + " --exclude=" + sub_dir.map{|d| d
|
|
43
|
-
cmd = "(cd #{File.dirname(dir)
|
|
54
|
+
exclude = exclude + " --exclude=" + sub_dir.map{|d| shell_name(d)}.join(" --exclude=") if sub_dir.length != 0
|
|
55
|
+
cmd = "(cd #{shell_name(File.dirname(dir))};tar -czvf #{shell_name(path)} #{exclude} #{shell_name(File.basename(dir))}" +
|
|
56
|
+
" > /dev/null 2>&1)"
|
|
44
57
|
S3log.debug(cmd)
|
|
45
58
|
system(cmd)
|
|
46
59
|
unless $?.success?
|
|
@@ -48,7 +61,7 @@ module S3backup
|
|
|
48
61
|
end
|
|
49
62
|
end
|
|
50
63
|
def from_tgz(path,dir)
|
|
51
|
-
cmd = "tar -xzvf #{path
|
|
64
|
+
cmd = "tar -xzvf #{shell_name(path)} -C #{shell_name(dir)} > /dev/null 2>&1"
|
|
52
65
|
S3log.debug(cmd)
|
|
53
66
|
system(cmd)
|
|
54
67
|
unless $?.success?
|
data/lib/s3backup/s3wrapper.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'aws/s3'
|
|
|
3
3
|
module S3backup
|
|
4
4
|
class S3Wrapper
|
|
5
5
|
attr_reader :bucket
|
|
6
|
+
MAX_TRY_COUNT = 5
|
|
6
7
|
def initialize(config,create_flg)
|
|
7
8
|
@bucket= nil
|
|
8
9
|
@s3objects =nil
|
|
@@ -54,7 +55,19 @@ module S3backup
|
|
|
54
55
|
def post(key,val)
|
|
55
56
|
key_name = CGI.escape(key)
|
|
56
57
|
S3log.info("S3Object.store(#{key_name})")
|
|
57
|
-
|
|
58
|
+
count = 0;
|
|
59
|
+
while count < MAX_TRY_COUNT do
|
|
60
|
+
begin
|
|
61
|
+
AWS::S3::S3Object.store(key_name,val,@bucket_name)
|
|
62
|
+
break;
|
|
63
|
+
rescue => ex
|
|
64
|
+
count+=1;
|
|
65
|
+
AWS::S3::Base.establish_connection!(args)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
if count >= MAX_TRY_COUNT
|
|
69
|
+
raise "post error occurd path #{key_name} \n"
|
|
70
|
+
end
|
|
58
71
|
end
|
|
59
72
|
def set_config(config)
|
|
60
73
|
err_msg = ""
|
data/lib/s3backup.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: s3backup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takeshi Morita
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-01-
|
|
12
|
+
date: 2010-01-18 00:00:00 +09:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -22,6 +22,26 @@ dependencies:
|
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
23
|
version: 0.6.2
|
|
24
24
|
version:
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: rubyforge
|
|
27
|
+
type: :development
|
|
28
|
+
version_requirement:
|
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.0.3
|
|
34
|
+
version:
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: gemcutter
|
|
37
|
+
type: :development
|
|
38
|
+
version_requirement:
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 0.3.0
|
|
44
|
+
version:
|
|
25
45
|
- !ruby/object:Gem::Dependency
|
|
26
46
|
name: hoe
|
|
27
47
|
type: :development
|
|
@@ -30,7 +50,7 @@ dependencies:
|
|
|
30
50
|
requirements:
|
|
31
51
|
- - ">="
|
|
32
52
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.
|
|
53
|
+
version: 2.5.0
|
|
34
54
|
version:
|
|
35
55
|
description: S3Backup is a backup tool to local directory to Amazon S3.
|
|
36
56
|
email:
|