selbackup 0.1.3 → 0.2.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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +138 -30
- data/Rakefile +7 -4
- data/lib/selbackup.rb +2 -1
- data/selbackup.gemspec +4 -4
- data/spec/selbackup_spec.rb +8 -9
- data/upload_test/create_files.sh +12 -6
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10947b2fe0ea712db590c2700b927473c301b610
|
4
|
+
data.tar.gz: aa319c2e8e037a72aad2d92bf02faf8c354036ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5399ac1a5e8937ed1c9b9ffdbf977bf9f610171589c319a8940203fa371bfe74860197b01679a8191fdc5636e5c653bd4e3fe3971ed7e0ee79dd8b69b4458c37
|
7
|
+
data.tar.gz: 055d5e4d7878d2a4632646a0253d94e433a8a641d56c08cfc2471a455895fed38ae4ec019d62608b1950212588857295f5319bd6d8e66fdf27eefa3c37f840dd
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
upload_test/tmp/
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,47 +1,155 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
CFPropertyList (2.3.1)
|
5
|
+
activesupport (4.2.4)
|
6
|
+
i18n (~> 0.7)
|
7
|
+
json (~> 1.7, >= 1.7.7)
|
8
|
+
minitest (~> 5.1)
|
9
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
10
|
+
tzinfo (~> 1.1)
|
7
11
|
builder (3.2.2)
|
8
|
-
diff-lcs (1.2.
|
9
|
-
excon (0.
|
10
|
-
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
excon (0.45.4)
|
14
|
+
fission (0.5.0)
|
15
|
+
CFPropertyList (~> 2.2)
|
16
|
+
fog (1.34.0)
|
17
|
+
fog-atmos
|
18
|
+
fog-aws (>= 0.6.0)
|
19
|
+
fog-brightbox (~> 0.4)
|
20
|
+
fog-core (~> 1.32)
|
21
|
+
fog-dynect (~> 0.0.2)
|
22
|
+
fog-ecloud (~> 0.1)
|
23
|
+
fog-google (>= 0.0.2)
|
24
|
+
fog-json
|
25
|
+
fog-local
|
26
|
+
fog-powerdns (>= 0.1.1)
|
27
|
+
fog-profitbricks
|
28
|
+
fog-radosgw (>= 0.0.2)
|
29
|
+
fog-riakcs
|
30
|
+
fog-sakuracloud (>= 0.0.4)
|
31
|
+
fog-serverlove
|
32
|
+
fog-softlayer
|
33
|
+
fog-storm_on_demand
|
34
|
+
fog-terremark
|
35
|
+
fog-vmfusion
|
36
|
+
fog-voxel
|
37
|
+
fog-xml (~> 0.1.1)
|
38
|
+
ipaddress (~> 0.5)
|
39
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
40
|
+
fog-atmos (0.1.0)
|
41
|
+
fog-core
|
42
|
+
fog-xml
|
43
|
+
fog-aws (0.7.6)
|
44
|
+
fog-core (~> 1.27)
|
45
|
+
fog-json (~> 1.0)
|
46
|
+
fog-xml (~> 0.1)
|
47
|
+
ipaddress (~> 0.8)
|
48
|
+
fog-brightbox (0.9.0)
|
49
|
+
fog-core (~> 1.22)
|
50
|
+
fog-json
|
51
|
+
inflecto (~> 0.0.2)
|
52
|
+
fog-core (1.32.1)
|
11
53
|
builder
|
12
|
-
excon (~> 0.
|
13
|
-
formatador (~> 0.2
|
54
|
+
excon (~> 0.45)
|
55
|
+
formatador (~> 0.2)
|
14
56
|
mime-types
|
15
|
-
multi_json (~> 1.0)
|
16
57
|
net-scp (~> 1.1)
|
17
58
|
net-ssh (>= 2.1.3)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
59
|
+
fog-dynect (0.0.2)
|
60
|
+
fog-core
|
61
|
+
fog-json
|
62
|
+
fog-xml
|
63
|
+
fog-ecloud (0.3.0)
|
64
|
+
fog-core
|
65
|
+
fog-xml
|
66
|
+
fog-google (0.0.7)
|
67
|
+
fog-core
|
68
|
+
fog-json
|
69
|
+
fog-xml
|
70
|
+
fog-json (1.0.2)
|
71
|
+
fog-core (~> 1.0)
|
72
|
+
multi_json (~> 1.10)
|
73
|
+
fog-local (0.2.1)
|
74
|
+
fog-core (~> 1.27)
|
75
|
+
fog-powerdns (0.1.1)
|
76
|
+
fog-core (~> 1.27)
|
77
|
+
fog-json (~> 1.0)
|
78
|
+
fog-xml (~> 0.1)
|
79
|
+
fog-profitbricks (0.0.5)
|
80
|
+
fog-core
|
81
|
+
fog-xml
|
82
|
+
nokogiri
|
83
|
+
fog-radosgw (0.0.4)
|
84
|
+
fog-core (>= 1.21.0)
|
85
|
+
fog-json
|
86
|
+
fog-xml (>= 0.0.1)
|
87
|
+
fog-riakcs (0.1.0)
|
88
|
+
fog-core
|
89
|
+
fog-json
|
90
|
+
fog-xml
|
91
|
+
fog-sakuracloud (1.1.1)
|
92
|
+
fog-core
|
93
|
+
fog-json
|
94
|
+
fog-serverlove (0.1.2)
|
95
|
+
fog-core
|
96
|
+
fog-json
|
97
|
+
fog-softlayer (0.4.7)
|
98
|
+
fog-core
|
99
|
+
fog-json
|
100
|
+
fog-storm_on_demand (0.1.1)
|
101
|
+
fog-core
|
102
|
+
fog-json
|
103
|
+
fog-terremark (0.1.0)
|
104
|
+
fog-core
|
105
|
+
fog-xml
|
106
|
+
fog-vmfusion (0.1.0)
|
107
|
+
fission
|
108
|
+
fog-core
|
109
|
+
fog-voxel (0.1.0)
|
110
|
+
fog-core
|
111
|
+
fog-xml
|
112
|
+
fog-xml (0.1.2)
|
113
|
+
fog-core
|
114
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
115
|
+
formatador (0.2.5)
|
116
|
+
i18n (0.7.0)
|
117
|
+
inflecto (0.0.2)
|
118
|
+
ipaddress (0.8.0)
|
119
|
+
json (1.8.3)
|
120
|
+
mime-types (2.6.1)
|
121
|
+
mini_portile (0.6.2)
|
122
|
+
minitest (5.8.0)
|
123
|
+
multi_json (1.11.2)
|
124
|
+
net-scp (1.2.1)
|
25
125
|
net-ssh (>= 2.6.5)
|
26
|
-
net-ssh (2.
|
27
|
-
nokogiri (1.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
rspec-
|
32
|
-
rspec-
|
33
|
-
|
34
|
-
rspec-
|
35
|
-
|
36
|
-
rspec-
|
37
|
-
|
126
|
+
net-ssh (2.9.2)
|
127
|
+
nokogiri (1.6.6.2)
|
128
|
+
mini_portile (~> 0.6.0)
|
129
|
+
rake (10.4.2)
|
130
|
+
rspec (3.3.0)
|
131
|
+
rspec-core (~> 3.3.0)
|
132
|
+
rspec-expectations (~> 3.3.0)
|
133
|
+
rspec-mocks (~> 3.3.0)
|
134
|
+
rspec-core (3.3.2)
|
135
|
+
rspec-support (~> 3.3.0)
|
136
|
+
rspec-expectations (3.3.1)
|
137
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
+
rspec-support (~> 3.3.0)
|
139
|
+
rspec-mocks (3.3.2)
|
140
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
141
|
+
rspec-support (~> 3.3.0)
|
142
|
+
rspec-support (3.3.0)
|
143
|
+
thread_safe (0.3.5)
|
144
|
+
tzinfo (1.2.2)
|
145
|
+
thread_safe (~> 0.1)
|
38
146
|
|
39
147
|
PLATFORMS
|
40
148
|
ruby
|
41
149
|
|
42
150
|
DEPENDENCIES
|
43
|
-
|
44
|
-
fog
|
151
|
+
activesupport (~> 4.2)
|
152
|
+
fog (~> 1.34)
|
45
153
|
i18n
|
46
154
|
rake
|
47
155
|
rspec
|
data/Rakefile
CHANGED
@@ -17,17 +17,20 @@ task :test_upload, :key, :secret, :bucket do |t, args|
|
|
17
17
|
secret = args[:secret]
|
18
18
|
bucket = args[:bucket]
|
19
19
|
|
20
|
-
|
20
|
+
puts 'Creating folders'
|
21
|
+
`mkdir -p upload_test/tmp/{tiny,large}/`
|
22
|
+
puts 'Creating fake files (124 tiny files and 4 large files (1GB, 5GB, 10GB, 25GB)'
|
21
23
|
`bash upload_test/create_files.sh`
|
22
24
|
begin
|
23
25
|
sb = SelBackup.new(key, secret, bucket)
|
24
|
-
files = Dir.glob(
|
26
|
+
files = Dir.glob('upload_test/tmp/tiny/*')
|
27
|
+
files.concat(Dir.glob('upload_test/tmp/large/*'))
|
25
28
|
files.each do | file |
|
26
29
|
puts "Uploading: #{file}"
|
27
30
|
sb.upload_file(file)
|
28
31
|
`rm #{file}`
|
29
32
|
end
|
30
|
-
rescue
|
31
|
-
puts
|
33
|
+
rescue => error
|
34
|
+
puts error.inspect
|
32
35
|
end
|
33
36
|
end
|
data/lib/selbackup.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support'
|
1
2
|
require 'active_support/core_ext'
|
2
3
|
require 'fog'
|
3
4
|
|
@@ -49,7 +50,7 @@ class SelBackup
|
|
49
50
|
#
|
50
51
|
# * If more than 7 daily files but less than one week datediff between the latest daily file and the most recent weekly file: deletes the latest daily file
|
51
52
|
#
|
52
|
-
# * If more than 7 daily files but less than one week datediff between the latest daily file and the most recent weekly file: pushes the latest daily file to weekly file
|
53
|
+
# * If more than 7 daily files but less than one week datediff between the latest daily file and the most recent weekly file: pushes the latest daily file to weekly file
|
53
54
|
# 2013-01-01-daily-file.tgz -> 2013-01-01-weekly-file.tgz
|
54
55
|
#
|
55
56
|
# Returns true if a file as been push. False in other cases
|
data/selbackup.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'selbackup'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '2015-09-
|
5
|
-
s.summary = "Backup to s3 with
|
6
|
-
s.description = "Backups files to
|
3
|
+
s.version = '0.2.0'
|
4
|
+
s.date = '2015-09-09'
|
5
|
+
s.summary = "Backup to s3 with rotation system"
|
6
|
+
s.description = "Backups files to Amazon S3 server"
|
7
7
|
s.has_rdoc = true
|
8
8
|
s.authors = ["Simon Ninon pour Selectra sarl"]
|
9
9
|
s.email = 'simon.ninon@gmail.com'
|
data/spec/selbackup_spec.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rspec/autorun'
|
2
1
|
require File.expand_path("../../lib/selbackup", __FILE__)
|
3
2
|
|
4
3
|
describe SelBackup do
|
@@ -31,55 +30,55 @@ describe SelBackup do
|
|
31
30
|
|
32
31
|
describe '#gen_daily_file' do
|
33
32
|
it 'pushes a file to daily' do
|
34
|
-
File.
|
33
|
+
allow(File).to receive(:open).and_return(nil)
|
35
34
|
file = '2013-01-01-file.tgz'
|
36
35
|
expectation = { myname: 'file.tgz', key: 'file.tgz/2013-01-01-daily-file.tgz', body: nil }
|
37
36
|
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
38
37
|
end
|
39
38
|
|
40
39
|
it 'has not an extension' do
|
41
|
-
File.
|
40
|
+
allow(File).to receive(:open).and_return(nil)
|
42
41
|
file = '2013-01-01-file'
|
43
42
|
expectation = { myname: 'file', key: 'file/2013-01-01-daily-file', body: nil }
|
44
43
|
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
45
44
|
end
|
46
45
|
|
47
46
|
it 'has not a date' do
|
48
|
-
File.
|
47
|
+
allow(File).to receive(:open).and_return(nil)
|
49
48
|
file = 'file.tgz'
|
50
49
|
expectation = { myname: 'file.tgz', key: "file.tgz/#{Date.today.to_s}-daily-file.tgz", body: nil }
|
51
50
|
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
52
51
|
end
|
53
52
|
|
54
53
|
it 'has not a date and an extension' do
|
55
|
-
File.
|
54
|
+
allow(File).to receive(:open).and_return(nil)
|
56
55
|
file = 'file'
|
57
56
|
expectation = { myname: 'file', key: "file/#{Date.today.to_s}-daily-file", body: nil }
|
58
57
|
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
59
58
|
end
|
60
59
|
|
61
60
|
it 'has an different extension and not a date' do
|
62
|
-
File.
|
61
|
+
allow(File).to receive(:open).and_return(nil)
|
63
62
|
file = 'file.myextension'
|
64
63
|
expectation = { myname: 'file.myextension', key: "file.myextension/#{Date.today.to_s}-daily-file.myextension", body: nil }
|
65
64
|
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
66
65
|
end
|
67
66
|
|
68
67
|
it 'has a different extension' do
|
69
|
-
File.
|
68
|
+
allow(File).to receive(:open).and_return(nil)
|
70
69
|
file = '2013-01-01-file.myextension'
|
71
70
|
expectation = { myname: 'file.myextension', key: 'file.myextension/2013-01-01-daily-file.myextension', body: nil }
|
72
71
|
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
73
72
|
end
|
74
73
|
|
75
74
|
it 'has only a date and an extension' do
|
76
|
-
File.
|
75
|
+
allow(File).to receive(:open).and_return(nil)
|
77
76
|
file = '2013-01-01.tgz'
|
78
77
|
expect(@selbackup.gen_daily_file(file)).to eq false
|
79
78
|
end
|
80
79
|
|
81
80
|
it 'has only a date' do
|
82
|
-
File.
|
81
|
+
allow(File).to receive(:open).and_return(nil)
|
83
82
|
file = '2013-01-01'
|
84
83
|
expect(@selbackup.gen_daily_file(file)).to eq false
|
85
84
|
end
|
data/upload_test/create_files.sh
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
for i in {1..4}; do
|
2
2
|
for j in {1..31}; do
|
3
3
|
if [[ $j -lt 10 ]]; then
|
4
|
-
echo "tmp/2013-0$i-0$j-file.tgz" > upload_test/tmp/2013-0$i-0$j-file.tgz
|
4
|
+
echo "tmp/tiny/2013-0$i-0$j-file.tgz" > upload_test/tmp/tiny/2013-0$i-0$j-file.tgz
|
5
5
|
else
|
6
|
-
echo "tmp/2013-0$i-$j-file.tgz" > upload_test/tmp/2013-0$i-$j-file.tgz
|
6
|
+
echo "tmp/tiny/2013-0$i-$j-file.tgz" > upload_test/tmp/tiny/2013-0$i-$j-file.tgz
|
7
7
|
fi
|
8
8
|
done
|
9
9
|
done
|
10
|
-
rm upload_test/tmp/2013-02-29-file.tgz
|
11
|
-
rm upload_test/tmp/2013-02-30-file.tgz
|
12
|
-
rm upload_test/tmp/2013-02-31-file.tgz
|
13
|
-
rm upload_test/tmp/2013-04-31-file.tgz
|
10
|
+
rm upload_test/tmp/tiny/2013-02-29-file.tgz
|
11
|
+
rm upload_test/tmp/tiny/2013-02-30-file.tgz
|
12
|
+
rm upload_test/tmp/tiny/2013-02-31-file.tgz
|
13
|
+
rm upload_test/tmp/tiny/2013-04-31-file.tgz
|
14
|
+
|
15
|
+
|
16
|
+
mkfile 1024m upload_test/tmp/large/1_1GB_file
|
17
|
+
mkfile 5120m upload_test/tmp/large/2_5GB_file
|
18
|
+
mkfile 10240m upload_test/tmp/large/3_10GB_file
|
19
|
+
mkfile 25600m upload_test/tmp/large/4_25GB_file
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selbackup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Ninon pour Selectra sarl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Backups files to
|
13
|
+
description: Backups files to Amazon S3 server
|
14
14
|
email: simon.ninon@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- ".gitignore"
|
19
20
|
- Gemfile
|
20
21
|
- Gemfile.lock
|
21
22
|
- LICENSE
|
@@ -50,6 +51,6 @@ rubyforge_project:
|
|
50
51
|
rubygems_version: 2.4.6
|
51
52
|
signing_key:
|
52
53
|
specification_version: 4
|
53
|
-
summary: Backup to s3 with
|
54
|
+
summary: Backup to s3 with rotation system
|
54
55
|
test_files:
|
55
56
|
- spec/selbackup_spec.rb
|