selbackup 0.1.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 +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +14 -0
- data/README.fr.md +82 -0
- data/README.md +83 -0
- data/Rakefile +26 -0
- data/doc/apple-touch-icon.png +0 -0
- data/doc/classes/Object.html +121 -0
- data/doc/classes/SelBackup.html +1387 -0
- data/doc/created.rid +6 -0
- data/doc/css/github.css +129 -0
- data/doc/css/main.css +333 -0
- data/doc/css/panel.css +384 -0
- data/doc/css/reset.css +48 -0
- data/doc/favicon.ico +0 -0
- data/doc/files/Gemfile.html +84 -0
- data/doc/files/Guardfile.html +147 -0
- data/doc/files/LICENSE.html +86 -0
- data/doc/files/Rakefile.html +101 -0
- data/doc/files/backup-to-s3_rb.html +85 -0
- data/doc/files/lib/selbackup_rb.html +89 -0
- data/doc/files/lib-backup_rb.html +89 -0
- data/doc/files/mv_files_rb.html +89 -0
- data/doc/files/spec/selbackup_spec_rb.html +76 -0
- data/doc/files/test/lib-backup_test_rb.html +76 -0
- data/doc/i/arrows.png +0 -0
- data/doc/i/results_bg.png +0 -0
- data/doc/i/tree_bg.png +0 -0
- data/doc/index.html +13 -0
- data/doc/js/highlight.pack.js +1 -0
- data/doc/js/jquery-1.3.2.min.js +19 -0
- data/doc/js/jquery-effect.js +593 -0
- data/doc/js/main.js +24 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searchdoc.js +449 -0
- data/doc/js/searcher.js +228 -0
- data/doc/panel/index.html +73 -0
- data/doc/panel/links.html +16 -0
- data/doc/panel/tree.js +1 -0
- data/lib/selbackup.rb +376 -0
- data/selbackup.gemspec +13 -0
- data/spec/selbackup_spec.rb +240 -0
- data/upload_test/create_files.sh +13 -0
- metadata +88 -0
data/selbackup.gemspec
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = 'selbackup'
|
|
3
|
+
s.version = '0.1.0'
|
|
4
|
+
s.date = '2013-07-19'
|
|
5
|
+
s.summary = "Backup to s3 with rtation system"
|
|
6
|
+
s.description = "Backups files to amazon s3 server"
|
|
7
|
+
s.has_rdoc = true
|
|
8
|
+
s.authors = ["Simon Ninon pour Selectra sarl"]
|
|
9
|
+
s.email = 'simon.ninon@gmail.com'
|
|
10
|
+
s.files = `git ls-files`.split("\n")
|
|
11
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
12
|
+
s.license = 'WTF'
|
|
13
|
+
end
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
require 'rspec/autorun'
|
|
2
|
+
require File.expand_path("../../lib/selbackup", __FILE__)
|
|
3
|
+
|
|
4
|
+
describe SelBackup do
|
|
5
|
+
before (:each) do
|
|
6
|
+
@selbackup = SelBackup.new('key', 'secret', 'bucket')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe '#initialize' do
|
|
10
|
+
it 'sets the access_key' do
|
|
11
|
+
expect(@selbackup.access_key).to eq 'key'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'sets the access_secret' do
|
|
15
|
+
expect(@selbackup.access_secret).to eq 'secret'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'sets the bucket_name' do
|
|
19
|
+
expect(@selbackup.bucket_name).to eq 'bucket'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'sets the region' do
|
|
23
|
+
@selbackup = SelBackup.new('key', 'secret', 'bucket', 'region')
|
|
24
|
+
expect(@selbackup.region).to eq 'region'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'does not set the region' do
|
|
28
|
+
expect(@selbackup.region).to eq 'eu-west-1'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#gen_daily_file' do
|
|
33
|
+
it 'pushes a file to daily' do
|
|
34
|
+
File.stub(:open).and_return(nil)
|
|
35
|
+
file = '2013-01-01-file.tgz'
|
|
36
|
+
expectation = { myname: 'file.tgz', key: 'file.tgz/2013-01-01-daily-file.tgz', body: nil }
|
|
37
|
+
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'has not an extension' do
|
|
41
|
+
File.stub(:open).and_return(nil)
|
|
42
|
+
file = '2013-01-01-file'
|
|
43
|
+
expectation = { myname: 'file', key: 'file/2013-01-01-daily-file', body: nil }
|
|
44
|
+
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'has not a date' do
|
|
48
|
+
File.stub(:open).and_return(nil)
|
|
49
|
+
file = 'file.tgz'
|
|
50
|
+
expectation = { myname: 'file.tgz', key: "file.tgz/#{Date.today.to_s}-daily-file.tgz", body: nil }
|
|
51
|
+
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'has not a date and an extension' do
|
|
55
|
+
File.stub(:open).and_return(nil)
|
|
56
|
+
file = 'file'
|
|
57
|
+
expectation = { myname: 'file', key: "file/#{Date.today.to_s}-daily-file", body: nil }
|
|
58
|
+
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'has an different extension and not a date' do
|
|
62
|
+
File.stub(:open).and_return(nil)
|
|
63
|
+
file = 'file.myextension'
|
|
64
|
+
expectation = { myname: 'file.myextension', key: "file.myextension/#{Date.today.to_s}-daily-file.myextension", body: nil }
|
|
65
|
+
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'has a different extension' do
|
|
69
|
+
File.stub(:open).and_return(nil)
|
|
70
|
+
file = '2013-01-01-file.myextension'
|
|
71
|
+
expectation = { myname: 'file.myextension', key: 'file.myextension/2013-01-01-daily-file.myextension', body: nil }
|
|
72
|
+
expect(@selbackup.gen_daily_file(file)).to include( expectation )
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'has only a date and an extension' do
|
|
76
|
+
File.stub(:open).and_return(nil)
|
|
77
|
+
file = '2013-01-01.tgz'
|
|
78
|
+
expect(@selbackup.gen_daily_file(file)).to eq false
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'has only a date' do
|
|
82
|
+
File.stub(:open).and_return(nil)
|
|
83
|
+
file = '2013-01-01'
|
|
84
|
+
expect(@selbackup.gen_daily_file(file)).to eq false
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe '#daily_good?' do
|
|
89
|
+
it 'gets 7 daily files' do
|
|
90
|
+
files = ['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7']
|
|
91
|
+
expect(@selbackup.daily_good?(files, 7)).to eq true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'gets more than 7 daily files' do
|
|
95
|
+
files = ['file1', 'file2', 'file3', 'file4', 'file5', 'file6', 'file7', 'file8']
|
|
96
|
+
expect(@selbackup.daily_good?(files, 7)).to eq false
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe '#should_weekly?' do
|
|
101
|
+
it 'has less than one week date diff' do
|
|
102
|
+
file1 = 'file.tgz/2013-01-02-daily-file.tgz'
|
|
103
|
+
file2 = 'file.tgz/2013-01-01-weekly-file.tgz'
|
|
104
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq false
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'has less than one week date diff and different syntax' do
|
|
108
|
+
file1 = 'file.tgz/daily-2013-01-02-file.tgz'
|
|
109
|
+
file2 = 'file.tgz/2013-01-01-weekly-file.tgz'
|
|
110
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq false
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
it 'has less than one week date diff and different syntax' do
|
|
115
|
+
file1 = 'file.tgz/daily-2013-01-02-file.tgz'
|
|
116
|
+
file2 = 'file.tgz/weekly-2013-01-01-file.tgz'
|
|
117
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq false
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'has less than one week date diff and different syntax' do
|
|
121
|
+
file1 = 'file.tgz/2013-01-02-daily-file.tgz'
|
|
122
|
+
file2 = 'file.tgz/weekly-2013-01-01-file.tgz'
|
|
123
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq false
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'has more than one week date diff' do
|
|
127
|
+
file1 = 'file.tgz/2013-01-09-daily-file.tgz'
|
|
128
|
+
file2 = 'file.tgz/2013-01-01-weekly-file.tgz'
|
|
129
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq true
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'has more than one week date diff and different syntax' do
|
|
133
|
+
file1 = 'file.tgz/daily-2013-01-09-file.tgz'
|
|
134
|
+
file2 = 'file.tgz/2013-01-01-weekly-file.tgz'
|
|
135
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq true
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it 'has more than one week date diff and different syntax' do
|
|
139
|
+
file1 = 'file.tgz/2013-01-09-daily-file.tgz'
|
|
140
|
+
file2 = 'file.tgz/weekly-2013-01-01-file.tgz'
|
|
141
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq true
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'has more than one week date diff and different syntax' do
|
|
145
|
+
file1 = 'file.tgz/daily-2013-01-09-file.tgz'
|
|
146
|
+
file2 = 'file.tgz/weekly-2013-01-01-file.tgz'
|
|
147
|
+
expect(@selbackup.should_weekly?(file1, file2)).to eq true
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe '#gen_weekly_file' do
|
|
152
|
+
it 'pushes a file to weekly' do
|
|
153
|
+
file = { key: 'file.tgz/2013-01-01-daily-file.tgz', body: 'file content'}
|
|
154
|
+
expectation = { key: 'file.tgz/2013-01-01-weekly-file.tgz', body: 'file content'}
|
|
155
|
+
expect(@selbackup.gen_weekly_file(file)).to include( expectation )
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
describe '#weekly_good?' do
|
|
160
|
+
it 'gets 4 weekly files' do
|
|
161
|
+
files = ['file1', 'file2', 'file3', 'file4']
|
|
162
|
+
expect(@selbackup.weekly_good?(files, 4)).to eq true
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it 'gets more than 4 weekly files' do
|
|
166
|
+
files = ['file1', 'file2', 'file3', 'file4', 'file5']
|
|
167
|
+
expect(@selbackup.weekly_good?(files, 4)).to eq false
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
describe '#should_monthly?' do
|
|
172
|
+
it 'has less than one month date diff' do
|
|
173
|
+
file1 = 'file.tgz/2013-02-02-weekly-file.tgz'
|
|
174
|
+
file2 = 'file.tgz/2013-02-01-monthly-file.tgz'
|
|
175
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq false
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it 'has less than one month date diff and different syntax ' do
|
|
179
|
+
file1 = 'file.tgz/weekly-2013-02-02-file.tgz'
|
|
180
|
+
file2 = 'file.tgz/monthly-2013-02-01-file.tgz'
|
|
181
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq false
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'has less than one month date diff and different syntax' do
|
|
185
|
+
file1 = 'file.tgz/weekly-2013-02-02-file.tgz'
|
|
186
|
+
file2 = 'file.tgz/2013-02-01-monthly-file.tgz'
|
|
187
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq false
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'has less than one month date diff and different syntax' do
|
|
191
|
+
file1 = 'file.tgz/2013-02-02-weekly-file.tgz'
|
|
192
|
+
file2 = 'file.tgz/monthly-2013-02-01-file.tgz'
|
|
193
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq false
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'has more than one month date diff' do
|
|
197
|
+
file1 = 'file.tgz/2013-02-02-weekly-file.tgz'
|
|
198
|
+
file2 = 'file.tgz/2013-01-01-monthly-file.tgz'
|
|
199
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq true
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it 'has more than one month date diff and different syntax' do
|
|
203
|
+
file1 = 'file.tgz/2013-02-02-weekly-file.tgz'
|
|
204
|
+
file2 = 'file.tgz/monthly-2013-01-01-file.tgz'
|
|
205
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq true
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it 'has more than one month date diff and different syntax' do
|
|
209
|
+
file1 = 'file.tgz/weekly-2013-02-02-file.tgz'
|
|
210
|
+
file2 = 'file.tgz/2013-01-01-monthly-file.tgz'
|
|
211
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq true
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it 'has more than one month date diff and different syntax' do
|
|
215
|
+
file1 = 'file.tgz/weekly-2013-02-02-file.tgz'
|
|
216
|
+
file2 = 'file.tgz/monthly-2013-01-01-file.tgz'
|
|
217
|
+
expect(@selbackup.should_monthly?(file1, file2)).to eq true
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
describe '#gen_monthly_file' do
|
|
222
|
+
it 'pushes a file to monthly' do
|
|
223
|
+
file = { key: 'file.tgz/2013-01-01-weekly-file.tgz', body: 'file content'}
|
|
224
|
+
expectation = { key: 'file.tgz/2013-01-01-monthly-file.tgz', body: 'file content'}
|
|
225
|
+
expect(@selbackup.gen_monthly_file(file)).to include( expectation )
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
describe '#monthly_good?' do
|
|
230
|
+
it 'gets 3 montly files' do
|
|
231
|
+
files = ['file1', 'file2', 'file3']
|
|
232
|
+
expect(@selbackup.monthly_good?(files, 3)).to eq true
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
it 'gets more than 3 monthly files' do
|
|
236
|
+
files = ['file1', 'file2', 'file3', 'file4']
|
|
237
|
+
expect(@selbackup.monthly_good?(files, 3)).to eq false
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
for i in {1..4}; do
|
|
2
|
+
for j in {1..31}; do
|
|
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
|
|
5
|
+
else
|
|
6
|
+
echo "tmp/2013-0$i-$j-file.tgz" > upload_test/tmp/2013-0$i-$j-file.tgz
|
|
7
|
+
fi
|
|
8
|
+
done
|
|
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
|
metadata
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: selbackup
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Simon Ninon pour Selectra sarl
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Backups files to amazon s3 server
|
|
14
|
+
email: simon.ninon@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- Gemfile
|
|
20
|
+
- Gemfile.lock
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.fr.md
|
|
23
|
+
- README.md
|
|
24
|
+
- Rakefile
|
|
25
|
+
- doc/apple-touch-icon.png
|
|
26
|
+
- doc/classes/Object.html
|
|
27
|
+
- doc/classes/SelBackup.html
|
|
28
|
+
- doc/created.rid
|
|
29
|
+
- doc/css/github.css
|
|
30
|
+
- doc/css/main.css
|
|
31
|
+
- doc/css/panel.css
|
|
32
|
+
- doc/css/reset.css
|
|
33
|
+
- doc/favicon.ico
|
|
34
|
+
- doc/files/Gemfile.html
|
|
35
|
+
- doc/files/Guardfile.html
|
|
36
|
+
- doc/files/LICENSE.html
|
|
37
|
+
- doc/files/Rakefile.html
|
|
38
|
+
- doc/files/backup-to-s3_rb.html
|
|
39
|
+
- doc/files/lib-backup_rb.html
|
|
40
|
+
- doc/files/lib/selbackup_rb.html
|
|
41
|
+
- doc/files/mv_files_rb.html
|
|
42
|
+
- doc/files/spec/selbackup_spec_rb.html
|
|
43
|
+
- doc/files/test/lib-backup_test_rb.html
|
|
44
|
+
- doc/i/arrows.png
|
|
45
|
+
- doc/i/results_bg.png
|
|
46
|
+
- doc/i/tree_bg.png
|
|
47
|
+
- doc/index.html
|
|
48
|
+
- doc/js/highlight.pack.js
|
|
49
|
+
- doc/js/jquery-1.3.2.min.js
|
|
50
|
+
- doc/js/jquery-effect.js
|
|
51
|
+
- doc/js/main.js
|
|
52
|
+
- doc/js/navigation.js
|
|
53
|
+
- doc/js/search_index.js
|
|
54
|
+
- doc/js/searchdoc.js
|
|
55
|
+
- doc/js/searcher.js
|
|
56
|
+
- doc/panel/index.html
|
|
57
|
+
- doc/panel/links.html
|
|
58
|
+
- doc/panel/tree.js
|
|
59
|
+
- lib/selbackup.rb
|
|
60
|
+
- selbackup.gemspec
|
|
61
|
+
- spec/selbackup_spec.rb
|
|
62
|
+
- upload_test/create_files.sh
|
|
63
|
+
homepage:
|
|
64
|
+
licenses:
|
|
65
|
+
- WTF
|
|
66
|
+
metadata: {}
|
|
67
|
+
post_install_message:
|
|
68
|
+
rdoc_options: []
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - '>='
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
requirements: []
|
|
82
|
+
rubyforge_project:
|
|
83
|
+
rubygems_version: 2.0.3
|
|
84
|
+
signing_key:
|
|
85
|
+
specification_version: 4
|
|
86
|
+
summary: Backup to s3 with rtation system
|
|
87
|
+
test_files:
|
|
88
|
+
- spec/selbackup_spec.rb
|