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
|
@@ -0,0 +1,1387 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
5
|
+
<head>
|
|
6
|
+
<title>SelBackup</title>
|
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
8
|
+
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
|
|
9
|
+
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
|
|
10
|
+
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
|
|
11
|
+
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
|
12
|
+
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
|
|
13
|
+
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
|
|
14
|
+
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
|
15
|
+
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
<div class="banner">
|
|
20
|
+
|
|
21
|
+
<h1>
|
|
22
|
+
<span class="type">Class</span>
|
|
23
|
+
SelBackup
|
|
24
|
+
|
|
25
|
+
<span class="parent"><
|
|
26
|
+
|
|
27
|
+
Object
|
|
28
|
+
|
|
29
|
+
</span>
|
|
30
|
+
|
|
31
|
+
</h1>
|
|
32
|
+
<ul class="files">
|
|
33
|
+
|
|
34
|
+
<li><a href="../files/lib/selbackup_rb.html">lib/selbackup.rb</a></li>
|
|
35
|
+
|
|
36
|
+
</ul>
|
|
37
|
+
</div>
|
|
38
|
+
<div id="bodyContent">
|
|
39
|
+
<div id="content">
|
|
40
|
+
|
|
41
|
+
<div class="description">
|
|
42
|
+
|
|
43
|
+
<p><a href="SelBackup.html">SelBackup</a> Class</p>
|
|
44
|
+
|
|
45
|
+
<p>Enables connection to s3 server and uploads files</p>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
<!-- Method ref -->
|
|
63
|
+
<div class="sectiontitle">Methods</div>
|
|
64
|
+
<dl class="methods">
|
|
65
|
+
|
|
66
|
+
<dt>B</dt>
|
|
67
|
+
<dd>
|
|
68
|
+
<ul>
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
<li>
|
|
72
|
+
<a href="#method-i-bucket">bucket</a>
|
|
73
|
+
</li>
|
|
74
|
+
|
|
75
|
+
</ul>
|
|
76
|
+
</dd>
|
|
77
|
+
|
|
78
|
+
<dt>C</dt>
|
|
79
|
+
<dd>
|
|
80
|
+
<ul>
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
<li>
|
|
84
|
+
<a href="#method-i-check_daily">check_daily</a>,
|
|
85
|
+
</li>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
<li>
|
|
89
|
+
<a href="#method-i-check_monthly">check_monthly</a>,
|
|
90
|
+
</li>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
<li>
|
|
94
|
+
<a href="#method-i-check_weekly">check_weekly</a>,
|
|
95
|
+
</li>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
<li>
|
|
99
|
+
<a href="#method-i-connection">connection</a>
|
|
100
|
+
</li>
|
|
101
|
+
|
|
102
|
+
</ul>
|
|
103
|
+
</dd>
|
|
104
|
+
|
|
105
|
+
<dt>D</dt>
|
|
106
|
+
<dd>
|
|
107
|
+
<ul>
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
<li>
|
|
111
|
+
<a href="#method-i-daily_good-3F">daily_good?</a>,
|
|
112
|
+
</li>
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
<li>
|
|
116
|
+
<a href="#method-i-delete_file">delete_file</a>,
|
|
117
|
+
</li>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
<li>
|
|
121
|
+
<a href="#method-i-directory">directory</a>
|
|
122
|
+
</li>
|
|
123
|
+
|
|
124
|
+
</ul>
|
|
125
|
+
</dd>
|
|
126
|
+
|
|
127
|
+
<dt>F</dt>
|
|
128
|
+
<dd>
|
|
129
|
+
<ul>
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
<li>
|
|
133
|
+
<a href="#method-i-files">files</a>
|
|
134
|
+
</li>
|
|
135
|
+
|
|
136
|
+
</ul>
|
|
137
|
+
</dd>
|
|
138
|
+
|
|
139
|
+
<dt>G</dt>
|
|
140
|
+
<dd>
|
|
141
|
+
<ul>
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
<li>
|
|
145
|
+
<a href="#method-i-gen_daily_file">gen_daily_file</a>,
|
|
146
|
+
</li>
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
<li>
|
|
150
|
+
<a href="#method-i-gen_monthly_file">gen_monthly_file</a>,
|
|
151
|
+
</li>
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
<li>
|
|
155
|
+
<a href="#method-i-gen_weekly_file">gen_weekly_file</a>,
|
|
156
|
+
</li>
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
<li>
|
|
160
|
+
<a href="#method-i-give_me_files">give_me_files</a>,
|
|
161
|
+
</li>
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
<li>
|
|
165
|
+
<a href="#method-i-give_me_latest_file">give_me_latest_file</a>,
|
|
166
|
+
</li>
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<li>
|
|
170
|
+
<a href="#method-i-give_me_recent_file">give_me_recent_file</a>
|
|
171
|
+
</li>
|
|
172
|
+
|
|
173
|
+
</ul>
|
|
174
|
+
</dd>
|
|
175
|
+
|
|
176
|
+
<dt>M</dt>
|
|
177
|
+
<dd>
|
|
178
|
+
<ul>
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
<li>
|
|
182
|
+
<a href="#method-i-monthly_good-3F">monthly_good?</a>
|
|
183
|
+
</li>
|
|
184
|
+
|
|
185
|
+
</ul>
|
|
186
|
+
</dd>
|
|
187
|
+
|
|
188
|
+
<dt>N</dt>
|
|
189
|
+
<dd>
|
|
190
|
+
<ul>
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
<li>
|
|
194
|
+
<a href="#method-c-new">new</a>
|
|
195
|
+
</li>
|
|
196
|
+
|
|
197
|
+
</ul>
|
|
198
|
+
</dd>
|
|
199
|
+
|
|
200
|
+
<dt>P</dt>
|
|
201
|
+
<dd>
|
|
202
|
+
<ul>
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<li>
|
|
206
|
+
<a href="#method-i-push_file">push_file</a>
|
|
207
|
+
</li>
|
|
208
|
+
|
|
209
|
+
</ul>
|
|
210
|
+
</dd>
|
|
211
|
+
|
|
212
|
+
<dt>S</dt>
|
|
213
|
+
<dd>
|
|
214
|
+
<ul>
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
<li>
|
|
218
|
+
<a href="#method-i-should_monthly-3F">should_monthly?</a>,
|
|
219
|
+
</li>
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
<li>
|
|
223
|
+
<a href="#method-i-should_weekly-3F">should_weekly?</a>
|
|
224
|
+
</li>
|
|
225
|
+
|
|
226
|
+
</ul>
|
|
227
|
+
</dd>
|
|
228
|
+
|
|
229
|
+
<dt>U</dt>
|
|
230
|
+
<dd>
|
|
231
|
+
<ul>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
<li>
|
|
235
|
+
<a href="#method-i-upload_file">upload_file</a>
|
|
236
|
+
</li>
|
|
237
|
+
|
|
238
|
+
</ul>
|
|
239
|
+
</dd>
|
|
240
|
+
|
|
241
|
+
<dt>W</dt>
|
|
242
|
+
<dd>
|
|
243
|
+
<ul>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
<li>
|
|
247
|
+
<a href="#method-i-weekly_good-3F">weekly_good?</a>
|
|
248
|
+
</li>
|
|
249
|
+
|
|
250
|
+
</ul>
|
|
251
|
+
</dd>
|
|
252
|
+
|
|
253
|
+
</dl>
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
<!-- Section attributes -->
|
|
271
|
+
<div class="sectiontitle">Attributes</div>
|
|
272
|
+
<table border='0' cellpadding='5'>
|
|
273
|
+
|
|
274
|
+
<tr valign='top'>
|
|
275
|
+
<td class='attr-rw'>
|
|
276
|
+
[RW]
|
|
277
|
+
</td>
|
|
278
|
+
<td class='attr-name'>access_key</td>
|
|
279
|
+
<td class='attr-desc'><p>Attributes: informations required for connection to s3 server</p></td>
|
|
280
|
+
</tr>
|
|
281
|
+
|
|
282
|
+
<tr valign='top'>
|
|
283
|
+
<td class='attr-rw'>
|
|
284
|
+
[RW]
|
|
285
|
+
</td>
|
|
286
|
+
<td class='attr-name'>access_secret</td>
|
|
287
|
+
<td class='attr-desc'><p>Attributes: informations required for connection to s3 server</p></td>
|
|
288
|
+
</tr>
|
|
289
|
+
|
|
290
|
+
<tr valign='top'>
|
|
291
|
+
<td class='attr-rw'>
|
|
292
|
+
[RW]
|
|
293
|
+
</td>
|
|
294
|
+
<td class='attr-name'>bucket_name</td>
|
|
295
|
+
<td class='attr-desc'><p>Attributes: informations required for connection to s3 server</p></td>
|
|
296
|
+
</tr>
|
|
297
|
+
|
|
298
|
+
<tr valign='top'>
|
|
299
|
+
<td class='attr-rw'>
|
|
300
|
+
[RW]
|
|
301
|
+
</td>
|
|
302
|
+
<td class='attr-name'>region</td>
|
|
303
|
+
<td class='attr-desc'><p>Attributes: informations required for connection to s3 server</p></td>
|
|
304
|
+
</tr>
|
|
305
|
+
|
|
306
|
+
</table>
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
<!-- Methods -->
|
|
311
|
+
|
|
312
|
+
<div class="sectiontitle">Class Public methods</div>
|
|
313
|
+
|
|
314
|
+
<div class="method">
|
|
315
|
+
<div class="title method-title" id="method-c-new">
|
|
316
|
+
|
|
317
|
+
<b>new</b>(key, secret, bucket, region = 'eu-west-1')
|
|
318
|
+
|
|
319
|
+
<a href="../classes/SelBackup.html#method-c-new" name="method-c-new" class="permalink">Link</a>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
<div class="description">
|
|
324
|
+
<p>Public: Initialize a new <a href="SelBackup.html">SelBackup</a> instance.</p>
|
|
325
|
+
<dl class="rdoc-list note-list"><dt>key
|
|
326
|
+
<dd>
|
|
327
|
+
<p>A String representing the AWS ACCESS KEY ID.</p>
|
|
328
|
+
</dd><dt>secret
|
|
329
|
+
<dd>
|
|
330
|
+
<p>A String representing the AWS ACCESS KEY SECRET.</p>
|
|
331
|
+
</dd><dt>bucket
|
|
332
|
+
<dd>
|
|
333
|
+
<p>A String representing the name of the bucket ot use.</p>
|
|
334
|
+
</dd><dt>:region (optional)
|
|
335
|
+
<dd>
|
|
336
|
+
<p>A String representing the region to conect to (default:
|
|
337
|
+
'eu-west-1').</p>
|
|
338
|
+
</dd></dl>
|
|
339
|
+
|
|
340
|
+
<p>Examples</p>
|
|
341
|
+
|
|
342
|
+
<pre>SelectraBackup.new('key', 'secret', 'bucket', region: 'us-east-1')</pre>
|
|
343
|
+
|
|
344
|
+
<p>Returns the newly instanciated object.</p>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
<div class="sourcecode">
|
|
353
|
+
|
|
354
|
+
<p class="source-link">
|
|
355
|
+
Source:
|
|
356
|
+
<a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
|
|
357
|
+
|
|
358
|
+
</p>
|
|
359
|
+
<div id="method-c-new_source" class="dyn-source">
|
|
360
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 28</span>
|
|
361
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">secret</span>, <span class="ruby-identifier">bucket</span>, <span class="ruby-identifier">region</span> = <span class="ruby-string">'eu-west-1'</span>)
|
|
362
|
+
<span class="ruby-ivar">@access_key</span> = <span class="ruby-identifier">key</span>
|
|
363
|
+
<span class="ruby-ivar">@access_secret</span> = <span class="ruby-identifier">secret</span>
|
|
364
|
+
<span class="ruby-ivar">@bucket_name</span> = <span class="ruby-identifier">bucket</span>
|
|
365
|
+
<span class="ruby-ivar">@region</span> = <span class="ruby-identifier">region</span>
|
|
366
|
+
<span class="ruby-keyword">end</span></pre>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
</div>
|
|
371
|
+
|
|
372
|
+
<div class="sectiontitle">Instance Public methods</div>
|
|
373
|
+
|
|
374
|
+
<div class="method">
|
|
375
|
+
<div class="title method-title" id="method-i-bucket">
|
|
376
|
+
|
|
377
|
+
<b>bucket</b>()
|
|
378
|
+
|
|
379
|
+
<a href="../classes/SelBackup.html#method-i-bucket" name="method-i-bucket" class="permalink">Link</a>
|
|
380
|
+
</div>
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
<div class="description">
|
|
384
|
+
<p>Public: Returns the S3 bucket.</p>
|
|
385
|
+
|
|
386
|
+
<p>Returns a Fog::Storage::AWS::Directory instance.</p>
|
|
387
|
+
</div>
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
<div class="sourcecode">
|
|
395
|
+
|
|
396
|
+
<p class="source-link">
|
|
397
|
+
Source:
|
|
398
|
+
<a href="javascript:toggleSource('method-i-bucket_source')" id="l_method-i-bucket_source">show</a>
|
|
399
|
+
|
|
400
|
+
</p>
|
|
401
|
+
<div id="method-i-bucket_source" class="dyn-source">
|
|
402
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 39</span>
|
|
403
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">bucket</span>
|
|
404
|
+
<span class="ruby-ivar">@bucket</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">bucket_name</span>)
|
|
405
|
+
<span class="ruby-keyword">end</span></pre>
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
</div>
|
|
410
|
+
|
|
411
|
+
<div class="method">
|
|
412
|
+
<div class="title method-title" id="method-i-check_daily">
|
|
413
|
+
|
|
414
|
+
<b>check_daily</b>(filename, nb_day)
|
|
415
|
+
|
|
416
|
+
<a href="../classes/SelBackup.html#method-i-check_daily" name="method-i-check_daily" class="permalink">Link</a>
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
<div class="description">
|
|
421
|
+
<p>Public: daily check algorythm</p>
|
|
422
|
+
<dl class="rdoc-list note-list"><dt>filename
|
|
423
|
+
<dd>
|
|
424
|
+
<p>String which contains a filename. If you upload
|
|
425
|
+
'2013-01-01-file.tgz', filename will be 'file.tgz'</p>
|
|
426
|
+
</dd></dl>
|
|
427
|
+
<ul><li>
|
|
428
|
+
<p>If 7 daily files or less: does nothing</p>
|
|
429
|
+
</li><li>
|
|
430
|
+
<p>If more than 7 daily files but less than one week datediff between the
|
|
431
|
+
latest daily file and the most recent weekly file: deletes the latest daily
|
|
432
|
+
file</p>
|
|
433
|
+
</li><li>
|
|
434
|
+
<p>If more than 7 daily files but less than one week datediff between the
|
|
435
|
+
latest daily file and the most recent weekly file: pushes the latest daily
|
|
436
|
+
file to weekly file</p>
|
|
437
|
+
|
|
438
|
+
<pre>2013-01-01-daily-file.tgz -> 2013-01-01-weekly-file.tgz</pre>
|
|
439
|
+
</li></ul>
|
|
440
|
+
|
|
441
|
+
<p>Returns true if a file as been push. False in other cases</p>
|
|
442
|
+
</div>
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
<div class="sourcecode">
|
|
450
|
+
|
|
451
|
+
<p class="source-link">
|
|
452
|
+
Source:
|
|
453
|
+
<a href="javascript:toggleSource('method-i-check_daily_source')" id="l_method-i-check_daily_source">show</a>
|
|
454
|
+
|
|
455
|
+
</p>
|
|
456
|
+
<div id="method-i-check_daily_source" class="dyn-source">
|
|
457
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 56</span>
|
|
458
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">check_daily</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">nb_day</span>)
|
|
459
|
+
<span class="ruby-identifier">return_value</span> = <span class="ruby-keyword">false</span>
|
|
460
|
+
<span class="ruby-identifier">daily_directory</span> = <span class="ruby-identifier">give_me_files</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">"daily"</span>)
|
|
461
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">daily_good?</span>(<span class="ruby-identifier">daily_directory</span>, <span class="ruby-identifier">nb_day</span>)
|
|
462
|
+
<span class="ruby-identifier">weekly_directory</span> = <span class="ruby-identifier">give_me_files</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">"weekly"</span>)
|
|
463
|
+
<span class="ruby-identifier">latest_daily_file</span> = <span class="ruby-identifier">give_me_latest_file</span>(<span class="ruby-identifier">daily_directory</span>)
|
|
464
|
+
<span class="ruby-identifier">recent_weekly_file</span> = <span class="ruby-identifier">give_me_recent_file</span>(<span class="ruby-identifier">weekly_directory</span>)
|
|
465
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">weekly_directory</span> <span class="ruby-operator">==</span> [] <span class="ruby-operator">||</span> <span class="ruby-identifier">should_weekly?</span>(<span class="ruby-identifier">latest_daily_file</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">recent_weekly_file</span>.<span class="ruby-identifier">key</span>)
|
|
466
|
+
<span class="ruby-identifier">weekly_file</span> = <span class="ruby-identifier">gen_weekly_file</span>({ <span class="ruby-identifier">key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">latest_daily_file</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">:</span> <span class="ruby-identifier">latest_daily_file</span>.<span class="ruby-identifier">body</span>})
|
|
467
|
+
<span class="ruby-identifier">push_file</span>(<span class="ruby-identifier">weekly_file</span>)
|
|
468
|
+
<span class="ruby-identifier">return_value</span> = <span class="ruby-keyword">true</span>
|
|
469
|
+
<span class="ruby-keyword">end</span>
|
|
470
|
+
<span class="ruby-identifier">delete_file</span>(<span class="ruby-identifier">latest_daily_file</span>)
|
|
471
|
+
<span class="ruby-keyword">end</span>
|
|
472
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">return_value</span>
|
|
473
|
+
<span class="ruby-keyword">end</span></pre>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
<div class="method">
|
|
480
|
+
<div class="title method-title" id="method-i-check_monthly">
|
|
481
|
+
|
|
482
|
+
<b>check_monthly</b>(filename, nb_month)
|
|
483
|
+
|
|
484
|
+
<a href="../classes/SelBackup.html#method-i-check_monthly" name="method-i-check_monthly" class="permalink">Link</a>
|
|
485
|
+
</div>
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
<div class="description">
|
|
489
|
+
<p>Public: montlhy check algorythm</p>
|
|
490
|
+
<dl class="rdoc-list note-list"><dt>filename
|
|
491
|
+
<dd>
|
|
492
|
+
<p>String which contains a filename. If you upload
|
|
493
|
+
'2013-01-01-file.tgz', filename will be 'file.tgz'</p>
|
|
494
|
+
</dd></dl>
|
|
495
|
+
<ul><li>
|
|
496
|
+
<p>If 3 monthly files or less: does nothing</p>
|
|
497
|
+
</li><li>
|
|
498
|
+
<p>if more than 3 monthly files: deletes the latest monthly file</p>
|
|
499
|
+
</li></ul>
|
|
500
|
+
|
|
501
|
+
<p>Returns true if a file as been delete. False in other cases</p>
|
|
502
|
+
</div>
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
<div class="sourcecode">
|
|
510
|
+
|
|
511
|
+
<p class="source-link">
|
|
512
|
+
Source:
|
|
513
|
+
<a href="javascript:toggleSource('method-i-check_monthly_source')" id="l_method-i-check_monthly_source">show</a>
|
|
514
|
+
|
|
515
|
+
</p>
|
|
516
|
+
<div id="method-i-check_monthly_source" class="dyn-source">
|
|
517
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 83</span>
|
|
518
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">check_monthly</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">nb_month</span>)
|
|
519
|
+
<span class="ruby-identifier">return_value</span> = <span class="ruby-keyword">false</span>
|
|
520
|
+
<span class="ruby-identifier">monthly_directory</span> = <span class="ruby-identifier">give_me_files</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">"monthly"</span>)
|
|
521
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">monthly_good?</span>(<span class="ruby-identifier">monthly_directory</span>, <span class="ruby-identifier">nb_month</span>)
|
|
522
|
+
<span class="ruby-identifier">latest_monthly_file</span> = <span class="ruby-identifier">give_me_latest_file</span>(<span class="ruby-identifier">monthly_directory</span>)
|
|
523
|
+
<span class="ruby-identifier">delete_file</span>(<span class="ruby-identifier">latest_monthly_file</span>)
|
|
524
|
+
<span class="ruby-identifier">return_value</span> = <span class="ruby-keyword">true</span>
|
|
525
|
+
<span class="ruby-keyword">end</span>
|
|
526
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">return_value</span>
|
|
527
|
+
<span class="ruby-keyword">end</span></pre>
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
</div>
|
|
532
|
+
|
|
533
|
+
<div class="method">
|
|
534
|
+
<div class="title method-title" id="method-i-check_weekly">
|
|
535
|
+
|
|
536
|
+
<b>check_weekly</b>(filename, nb_week)
|
|
537
|
+
|
|
538
|
+
<a href="../classes/SelBackup.html#method-i-check_weekly" name="method-i-check_weekly" class="permalink">Link</a>
|
|
539
|
+
</div>
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
<div class="description">
|
|
543
|
+
<p>Public: weekly check algorythm</p>
|
|
544
|
+
<dl class="rdoc-list note-list"><dt>filename
|
|
545
|
+
<dd>
|
|
546
|
+
<p>String which contains a filename. If you upload
|
|
547
|
+
'2013-01-01-file.tgz', filename will be 'file.tgz'</p>
|
|
548
|
+
</dd></dl>
|
|
549
|
+
<ul><li>
|
|
550
|
+
<p>If 4 weekly files or less: does nothing</p>
|
|
551
|
+
</li><li>
|
|
552
|
+
<p>If more than 4 weekly files but less than one month datediff between the
|
|
553
|
+
latest weekly file and the most recent monthly file: deletes the latest
|
|
554
|
+
weekly file</p>
|
|
555
|
+
</li><li>
|
|
556
|
+
<p>If more than 4 weekly files but less than one week datediff between the
|
|
557
|
+
latest weekly file and the most recent monthly file: pushes the latest
|
|
558
|
+
weekly file to monthly file</p>
|
|
559
|
+
|
|
560
|
+
<pre>2013-01-01-weekly-file.tgz -> 2013-01-01-monthly-file.tgz</pre>
|
|
561
|
+
</li></ul>
|
|
562
|
+
|
|
563
|
+
<p>Returns true if a file as been push. False in other cases</p>
|
|
564
|
+
</div>
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
<div class="sourcecode">
|
|
572
|
+
|
|
573
|
+
<p class="source-link">
|
|
574
|
+
Source:
|
|
575
|
+
<a href="javascript:toggleSource('method-i-check_weekly_source')" id="l_method-i-check_weekly_source">show</a>
|
|
576
|
+
|
|
577
|
+
</p>
|
|
578
|
+
<div id="method-i-check_weekly_source" class="dyn-source">
|
|
579
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 107</span>
|
|
580
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">check_weekly</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">nb_week</span>)
|
|
581
|
+
<span class="ruby-identifier">return_value</span> = <span class="ruby-keyword">false</span>
|
|
582
|
+
<span class="ruby-identifier">weekly_directory</span> = <span class="ruby-identifier">give_me_files</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">"weekly"</span>)
|
|
583
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">weekly_good?</span>(<span class="ruby-identifier">weekly_directory</span>, <span class="ruby-identifier">nb_week</span>)
|
|
584
|
+
<span class="ruby-identifier">monthly_directory</span> = <span class="ruby-identifier">give_me_files</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-string">"monthly"</span>)
|
|
585
|
+
<span class="ruby-identifier">latest_weekly_file</span> = <span class="ruby-identifier">give_me_latest_file</span>(<span class="ruby-identifier">weekly_directory</span>)
|
|
586
|
+
<span class="ruby-identifier">recent_monthly_file</span> = <span class="ruby-identifier">give_me_recent_file</span>(<span class="ruby-identifier">monthly_directory</span>)
|
|
587
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">monthly_directory</span> <span class="ruby-operator">==</span> [] <span class="ruby-operator">||</span> <span class="ruby-identifier">should_monthly?</span>(<span class="ruby-identifier">latest_weekly_file</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">recent_monthly_file</span>.<span class="ruby-identifier">key</span>)
|
|
588
|
+
<span class="ruby-identifier">monthly_file</span> = <span class="ruby-identifier">gen_monthly_file</span>({ <span class="ruby-identifier">key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">latest_weekly_file</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">:</span> <span class="ruby-identifier">latest_weekly_file</span>.<span class="ruby-identifier">body</span>})
|
|
589
|
+
<span class="ruby-identifier">push_file</span>(<span class="ruby-identifier">monthly_file</span>)
|
|
590
|
+
<span class="ruby-identifier">return_value</span> = <span class="ruby-keyword">true</span>
|
|
591
|
+
<span class="ruby-keyword">end</span>
|
|
592
|
+
<span class="ruby-identifier">delete_file</span>(<span class="ruby-identifier">latest_weekly_file</span>)
|
|
593
|
+
<span class="ruby-keyword">end</span>
|
|
594
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">return_value</span>
|
|
595
|
+
<span class="ruby-keyword">end</span></pre>
|
|
596
|
+
</div>
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
</div>
|
|
600
|
+
|
|
601
|
+
<div class="method">
|
|
602
|
+
<div class="title method-title" id="method-i-connection">
|
|
603
|
+
|
|
604
|
+
<b>connection</b>()
|
|
605
|
+
|
|
606
|
+
<a href="../classes/SelBackup.html#method-i-connection" name="method-i-connection" class="permalink">Link</a>
|
|
607
|
+
</div>
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
<div class="description">
|
|
611
|
+
<p>Public: Returns the S3 connection.</p>
|
|
612
|
+
|
|
613
|
+
<p>Returns a Fog::Storage::AWS::Real instance.</p>
|
|
614
|
+
</div>
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
<div class="sourcecode">
|
|
622
|
+
|
|
623
|
+
<p class="source-link">
|
|
624
|
+
Source:
|
|
625
|
+
<a href="javascript:toggleSource('method-i-connection_source')" id="l_method-i-connection_source">show</a>
|
|
626
|
+
|
|
627
|
+
</p>
|
|
628
|
+
<div id="method-i-connection_source" class="dyn-source">
|
|
629
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 128</span>
|
|
630
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">connection</span>
|
|
631
|
+
<span class="ruby-ivar">@connection</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Fog</span><span class="ruby-operator">::</span><span class="ruby-constant">Storage</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">provider</span><span class="ruby-operator">:</span> <span class="ruby-string">'AWS'</span>, <span class="ruby-identifier">aws_access_key_id</span><span class="ruby-operator">:</span> <span class="ruby-identifier">access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">access_secret</span>, <span class="ruby-identifier">region</span><span class="ruby-operator">:</span> <span class="ruby-identifier">region</span>)
|
|
632
|
+
<span class="ruby-keyword">end</span></pre>
|
|
633
|
+
</div>
|
|
634
|
+
</div>
|
|
635
|
+
|
|
636
|
+
</div>
|
|
637
|
+
|
|
638
|
+
<div class="method">
|
|
639
|
+
<div class="title method-title" id="method-i-daily_good-3F">
|
|
640
|
+
|
|
641
|
+
<b>daily_good?</b>(directoryFiles, nb_day)
|
|
642
|
+
|
|
643
|
+
<a href="../classes/SelBackup.html#method-i-daily_good-3F" name="method-i-daily_good-3F" class="permalink">Link</a>
|
|
644
|
+
</div>
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
<div class="description">
|
|
648
|
+
<p>Public: Check daily files number</p>
|
|
649
|
+
<dl class="rdoc-list note-list"><dt>directoryFiles
|
|
650
|
+
<dd>
|
|
651
|
+
<p>Array of daily files</p>
|
|
652
|
+
</dd></dl>
|
|
653
|
+
|
|
654
|
+
<pre>['file/2013-01-01-daily-file.tgz', 'file/2013-01-02-daily-file.tgz', ...]</pre>
|
|
655
|
+
|
|
656
|
+
<p>Returns false if there is more than 7 daily files. False in other cases</p>
|
|
657
|
+
</div>
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
<div class="sourcecode">
|
|
665
|
+
|
|
666
|
+
<p class="source-link">
|
|
667
|
+
Source:
|
|
668
|
+
<a href="javascript:toggleSource('method-i-daily_good-3F_source')" id="l_method-i-daily_good-3F_source">show</a>
|
|
669
|
+
|
|
670
|
+
</p>
|
|
671
|
+
<div id="method-i-daily_good-3F_source" class="dyn-source">
|
|
672
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 139</span>
|
|
673
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">daily_good?</span>(<span class="ruby-identifier">directoryFiles</span>, <span class="ruby-identifier">nb_day</span>)
|
|
674
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">directoryFiles</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-identifier">nb_day</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>;
|
|
675
|
+
<span class="ruby-keyword">end</span></pre>
|
|
676
|
+
</div>
|
|
677
|
+
</div>
|
|
678
|
+
|
|
679
|
+
</div>
|
|
680
|
+
|
|
681
|
+
<div class="method">
|
|
682
|
+
<div class="title method-title" id="method-i-delete_file">
|
|
683
|
+
|
|
684
|
+
<b>delete_file</b>(file)
|
|
685
|
+
|
|
686
|
+
<a href="../classes/SelBackup.html#method-i-delete_file" name="method-i-delete_file" class="permalink">Link</a>
|
|
687
|
+
</div>
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
<div class="description">
|
|
691
|
+
<p>Public: deletes a file</p>
|
|
692
|
+
<dl class="rdoc-list note-list"><dt>file
|
|
693
|
+
<dd>
|
|
694
|
+
<p>Fog::Storage::AWS::Files file</p>
|
|
695
|
+
</dd></dl>
|
|
696
|
+
|
|
697
|
+
<p>returns nothing</p>
|
|
698
|
+
</div>
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
<div class="sourcecode">
|
|
706
|
+
|
|
707
|
+
<p class="source-link">
|
|
708
|
+
Source:
|
|
709
|
+
<a href="javascript:toggleSource('method-i-delete_file_source')" id="l_method-i-delete_file_source">show</a>
|
|
710
|
+
|
|
711
|
+
</p>
|
|
712
|
+
<div id="method-i-delete_file_source" class="dyn-source">
|
|
713
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 149</span>
|
|
714
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">delete_file</span>(<span class="ruby-identifier">file</span>)
|
|
715
|
+
<span class="ruby-identifier">file</span>.<span class="ruby-identifier">destroy</span>
|
|
716
|
+
<span class="ruby-keyword">end</span></pre>
|
|
717
|
+
</div>
|
|
718
|
+
</div>
|
|
719
|
+
|
|
720
|
+
</div>
|
|
721
|
+
|
|
722
|
+
<div class="method">
|
|
723
|
+
<div class="title method-title" id="method-i-directory">
|
|
724
|
+
|
|
725
|
+
<b>directory</b>(path)
|
|
726
|
+
|
|
727
|
+
<a href="../classes/SelBackup.html#method-i-directory" name="method-i-directory" class="permalink">Link</a>
|
|
728
|
+
</div>
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
<div class="description">
|
|
732
|
+
<p>Public: Returns a virtual S3 directory.</p>
|
|
733
|
+
|
|
734
|
+
<p>S3 doesn't know such a thing as a directory but it is possible to use a
|
|
735
|
+
prefix to select only the files having a key starting with this prefix.</p>
|
|
736
|
+
<dl class="rdoc-list note-list"><dt>path
|
|
737
|
+
<dd>
|
|
738
|
+
<p>A String representing the prefix to use.</p>
|
|
739
|
+
</dd></dl>
|
|
740
|
+
|
|
741
|
+
<p>Examples</p>
|
|
742
|
+
|
|
743
|
+
<pre class="ruby"><span class="ruby-identifier">sb</span> = <span class="ruby-constant">SelectraBackup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'key'</span>, <span class="ruby-string">'secret'</span>, <span class="ruby-string">'bucket'</span>)
|
|
744
|
+
<span class="ruby-identifier">backup</span> = <span class="ruby-identifier">sb</span>.<span class="ruby-identifier">directory</span>(<span class="ruby-string">'backup/'</span>)
|
|
745
|
+
<span class="ruby-identifier">backup</span>.<span class="ruby-identifier">files</span>
|
|
746
|
+
<span class="ruby-comment"># => <Fog::Storage::AWS::Files ...></span>
|
|
747
|
+
</pre>
|
|
748
|
+
|
|
749
|
+
<p>Returns a Fog::Storage::AWS::Directory instance.</p>
|
|
750
|
+
</div>
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
<div class="sourcecode">
|
|
758
|
+
|
|
759
|
+
<p class="source-link">
|
|
760
|
+
Source:
|
|
761
|
+
<a href="javascript:toggleSource('method-i-directory_source')" id="l_method-i-directory_source">show</a>
|
|
762
|
+
|
|
763
|
+
</p>
|
|
764
|
+
<div id="method-i-directory_source" class="dyn-source">
|
|
765
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 168</span>
|
|
766
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">directory</span>(<span class="ruby-identifier">path</span>)
|
|
767
|
+
<span class="ruby-identifier">connection</span>.<span class="ruby-identifier">directories</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">prefix</span><span class="ruby-operator">:</span> <span class="ruby-identifier">path</span>)
|
|
768
|
+
<span class="ruby-keyword">end</span></pre>
|
|
769
|
+
</div>
|
|
770
|
+
</div>
|
|
771
|
+
|
|
772
|
+
</div>
|
|
773
|
+
|
|
774
|
+
<div class="method">
|
|
775
|
+
<div class="title method-title" id="method-i-files">
|
|
776
|
+
|
|
777
|
+
<b>files</b>()
|
|
778
|
+
|
|
779
|
+
<a href="../classes/SelBackup.html#method-i-files" name="method-i-files" class="permalink">Link</a>
|
|
780
|
+
</div>
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
<div class="description">
|
|
784
|
+
<p>Public: Returns the list of files.</p>
|
|
785
|
+
|
|
786
|
+
<p>Returns a Fog::Storage::AWS::Files instances.</p>
|
|
787
|
+
</div>
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
<div class="sourcecode">
|
|
795
|
+
|
|
796
|
+
<p class="source-link">
|
|
797
|
+
Source:
|
|
798
|
+
<a href="javascript:toggleSource('method-i-files_source')" id="l_method-i-files_source">show</a>
|
|
799
|
+
|
|
800
|
+
</p>
|
|
801
|
+
<div id="method-i-files_source" class="dyn-source">
|
|
802
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 176</span>
|
|
803
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">files</span>
|
|
804
|
+
<span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">files</span>
|
|
805
|
+
<span class="ruby-keyword">end</span></pre>
|
|
806
|
+
</div>
|
|
807
|
+
</div>
|
|
808
|
+
|
|
809
|
+
</div>
|
|
810
|
+
|
|
811
|
+
<div class="method">
|
|
812
|
+
<div class="title method-title" id="method-i-gen_daily_file">
|
|
813
|
+
|
|
814
|
+
<b>gen_daily_file</b>(file)
|
|
815
|
+
|
|
816
|
+
<a href="../classes/SelBackup.html#method-i-gen_daily_file" name="method-i-gen_daily_file" class="permalink">Link</a>
|
|
817
|
+
</div>
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
<div class="description">
|
|
821
|
+
<p>Public: gen a daily file</p>
|
|
822
|
+
<dl class="rdoc-list note-list"><dt>file
|
|
823
|
+
<dd>
|
|
824
|
+
<p>file you want to upload</p>
|
|
825
|
+
</dd></dl>
|
|
826
|
+
|
|
827
|
+
<p>Returns an hash containing the filename, the key and the body of the daily
|
|
828
|
+
file</p>
|
|
829
|
+
</div>
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
<div class="sourcecode">
|
|
837
|
+
|
|
838
|
+
<p class="source-link">
|
|
839
|
+
Source:
|
|
840
|
+
<a href="javascript:toggleSource('method-i-gen_daily_file_source')" id="l_method-i-gen_daily_file_source">show</a>
|
|
841
|
+
|
|
842
|
+
</p>
|
|
843
|
+
<div id="method-i-gen_daily_file_source" class="dyn-source">
|
|
844
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 249</span>
|
|
845
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">gen_daily_file</span>(<span class="ruby-identifier">file</span>)
|
|
846
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">file</span>)
|
|
847
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.\w*)?$/</span>
|
|
848
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
|
849
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[0-9]{4}-[0-9]{2}-[0-9]{2}-/</span>)
|
|
850
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-node">"#{Date.today.to_s}-#{name}"</span>
|
|
851
|
+
<span class="ruby-keyword">end</span>
|
|
852
|
+
<span class="ruby-identifier">myname</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/[0-9]{4}-[0-9]{2}-[0-9]{2}-/</span>).<span class="ruby-identifier">last</span>
|
|
853
|
+
<span class="ruby-identifier">mydate</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-node">"-#{myname}"</span>).<span class="ruby-identifier">first</span>
|
|
854
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-node">"#{myname}/#{mydate}-daily-#{myname}"</span>
|
|
855
|
+
<span class="ruby-keyword">return</span> { <span class="ruby-identifier">myname</span><span class="ruby-operator">:</span> <span class="ruby-identifier">myname</span>, <span class="ruby-identifier">key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">key</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">:</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file</span>) }
|
|
856
|
+
<span class="ruby-keyword">end</span></pre>
|
|
857
|
+
</div>
|
|
858
|
+
</div>
|
|
859
|
+
|
|
860
|
+
</div>
|
|
861
|
+
|
|
862
|
+
<div class="method">
|
|
863
|
+
<div class="title method-title" id="method-i-gen_monthly_file">
|
|
864
|
+
|
|
865
|
+
<b>gen_monthly_file</b>(file)
|
|
866
|
+
|
|
867
|
+
<a href="../classes/SelBackup.html#method-i-gen_monthly_file" name="method-i-gen_monthly_file" class="permalink">Link</a>
|
|
868
|
+
</div>
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
<div class="description">
|
|
872
|
+
<p>Public: gen a monthly file</p>
|
|
873
|
+
<dl class="rdoc-list note-list"><dt>file
|
|
874
|
+
<dd>
|
|
875
|
+
<p>hash containing the key and the body of the weekly file you want to push to
|
|
876
|
+
monthly file</p>
|
|
877
|
+
</dd></dl>
|
|
878
|
+
|
|
879
|
+
<p>Returns an hash containing the key and the body of the monthly file</p>
|
|
880
|
+
</div>
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
<div class="sourcecode">
|
|
888
|
+
|
|
889
|
+
<p class="source-link">
|
|
890
|
+
Source:
|
|
891
|
+
<a href="javascript:toggleSource('method-i-gen_monthly_file_source')" id="l_method-i-gen_monthly_file_source">show</a>
|
|
892
|
+
|
|
893
|
+
</p>
|
|
894
|
+
<div id="method-i-gen_monthly_file_source" class="dyn-source">
|
|
895
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 268</span>
|
|
896
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">gen_monthly_file</span>(<span class="ruby-identifier">file</span>)
|
|
897
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[\w+.-]+\/[\w+.-]+-\d{4}-\d{2}-\d{2}-[\w+.-]+/</span>
|
|
898
|
+
<span class="ruby-identifier">monthly_name</span> = <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-string">"/weekly-"</span>, <span class="ruby-string">"/monthy-"</span>)
|
|
899
|
+
<span class="ruby-keyword">else</span>
|
|
900
|
+
<span class="ruby-identifier">monthly_name</span> = <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-string">"-weekly-"</span>, <span class="ruby-string">"-monthly-"</span>)
|
|
901
|
+
<span class="ruby-keyword">end</span>
|
|
902
|
+
<span class="ruby-keyword">return</span> { <span class="ruby-identifier">key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">monthly_name</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">:</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:body</span>] }
|
|
903
|
+
<span class="ruby-keyword">end</span></pre>
|
|
904
|
+
</div>
|
|
905
|
+
</div>
|
|
906
|
+
|
|
907
|
+
</div>
|
|
908
|
+
|
|
909
|
+
<div class="method">
|
|
910
|
+
<div class="title method-title" id="method-i-gen_weekly_file">
|
|
911
|
+
|
|
912
|
+
<b>gen_weekly_file</b>(file)
|
|
913
|
+
|
|
914
|
+
<a href="../classes/SelBackup.html#method-i-gen_weekly_file" name="method-i-gen_weekly_file" class="permalink">Link</a>
|
|
915
|
+
</div>
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
<div class="description">
|
|
919
|
+
<p>Public: gen a weekly file</p>
|
|
920
|
+
<dl class="rdoc-list note-list"><dt>file
|
|
921
|
+
<dd>
|
|
922
|
+
<p>hash containing the key and the body of the daily file you want to push to
|
|
923
|
+
weekly file</p>
|
|
924
|
+
</dd></dl>
|
|
925
|
+
|
|
926
|
+
<p>Returns an hash containing the key and the body of the weekly file</p>
|
|
927
|
+
</div>
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
<div class="sourcecode">
|
|
935
|
+
|
|
936
|
+
<p class="source-link">
|
|
937
|
+
Source:
|
|
938
|
+
<a href="javascript:toggleSource('method-i-gen_weekly_file_source')" id="l_method-i-gen_weekly_file_source">show</a>
|
|
939
|
+
|
|
940
|
+
</p>
|
|
941
|
+
<div id="method-i-gen_weekly_file_source" class="dyn-source">
|
|
942
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 283</span>
|
|
943
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">gen_weekly_file</span>(<span class="ruby-identifier">file</span>)
|
|
944
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[\w+.-]+\/[\w+.-]+-\d{4}-\d{2}-\d{2}-[\w+.-]+/</span>
|
|
945
|
+
<span class="ruby-identifier">weekly_name</span> = <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-string">"/daily-"</span>, <span class="ruby-string">"/weekly-"</span>)
|
|
946
|
+
<span class="ruby-keyword">else</span>
|
|
947
|
+
<span class="ruby-identifier">weekly_name</span> = <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-string">"-daily-"</span>, <span class="ruby-string">"-weekly-"</span>)
|
|
948
|
+
<span class="ruby-keyword">end</span>
|
|
949
|
+
<span class="ruby-keyword">return</span> { <span class="ruby-identifier">key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">weekly_name</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">:</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:body</span>] }
|
|
950
|
+
<span class="ruby-keyword">end</span></pre>
|
|
951
|
+
</div>
|
|
952
|
+
</div>
|
|
953
|
+
|
|
954
|
+
</div>
|
|
955
|
+
|
|
956
|
+
<div class="method">
|
|
957
|
+
<div class="title method-title" id="method-i-give_me_files">
|
|
958
|
+
|
|
959
|
+
<b>give_me_files</b>(filename, type)
|
|
960
|
+
|
|
961
|
+
<a href="../classes/SelBackup.html#method-i-give_me_files" name="method-i-give_me_files" class="permalink">Link</a>
|
|
962
|
+
</div>
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
<div class="description">
|
|
966
|
+
<p>Public: returns lists of file</p>
|
|
967
|
+
|
|
968
|
+
<p>filename: “file.tgz” for example</p>
|
|
969
|
+
|
|
970
|
+
<p>type: specify if you want daily, weekly or monthly files</p>
|
|
971
|
+
|
|
972
|
+
<p>Returns a sorted array</p>
|
|
973
|
+
</div>
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
<div class="sourcecode">
|
|
981
|
+
|
|
982
|
+
<p class="source-link">
|
|
983
|
+
Source:
|
|
984
|
+
<a href="javascript:toggleSource('method-i-give_me_files_source')" id="l_method-i-give_me_files_source">show</a>
|
|
985
|
+
|
|
986
|
+
</p>
|
|
987
|
+
<div id="method-i-give_me_files_source" class="dyn-source">
|
|
988
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 188</span>
|
|
989
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">give_me_files</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">type</span>)
|
|
990
|
+
<span class="ruby-identifier">full_directory</span> = <span class="ruby-identifier">directory</span>(<span class="ruby-node">"#{filename}/"</span>)
|
|
991
|
+
<span class="ruby-identifier">files</span> = []
|
|
992
|
+
<span class="ruby-identifier">full_directory</span>.<span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
|
993
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/#{filename}\/\d{4}-\d{2}-\d{2}-#{type}-[\w+.]+/</span> <span class="ruby-operator">||</span>
|
|
994
|
+
<span class="ruby-identifier">file</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/#{filename}\/#{type}-\d{4}-\d{2}-\d{2}-[\w+.]+/</span>
|
|
995
|
+
<span class="ruby-identifier">files</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">file</span>)
|
|
996
|
+
<span class="ruby-keyword">end</span>
|
|
997
|
+
<span class="ruby-keyword">end</span>
|
|
998
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">files</span>
|
|
999
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1000
|
+
</div>
|
|
1001
|
+
</div>
|
|
1002
|
+
|
|
1003
|
+
</div>
|
|
1004
|
+
|
|
1005
|
+
<div class="method">
|
|
1006
|
+
<div class="title method-title" id="method-i-give_me_latest_file">
|
|
1007
|
+
|
|
1008
|
+
<b>give_me_latest_file</b>(files)
|
|
1009
|
+
|
|
1010
|
+
<a href="../classes/SelBackup.html#method-i-give_me_latest_file" name="method-i-give_me_latest_file" class="permalink">Link</a>
|
|
1011
|
+
</div>
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
<div class="description">
|
|
1015
|
+
<p>Public: returns latest file</p>
|
|
1016
|
+
|
|
1017
|
+
<p>files: array of AWS object file</p>
|
|
1018
|
+
|
|
1019
|
+
<p>Returns the latest file, based on the date</p>
|
|
1020
|
+
</div>
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
<div class="sourcecode">
|
|
1028
|
+
|
|
1029
|
+
<p class="source-link">
|
|
1030
|
+
Source:
|
|
1031
|
+
<a href="javascript:toggleSource('method-i-give_me_latest_file_source')" id="l_method-i-give_me_latest_file_source">show</a>
|
|
1032
|
+
|
|
1033
|
+
</p>
|
|
1034
|
+
<div id="method-i-give_me_latest_file_source" class="dyn-source">
|
|
1035
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 206</span>
|
|
1036
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">give_me_latest_file</span>(<span class="ruby-identifier">files</span>)
|
|
1037
|
+
<span class="ruby-identifier">latest_file</span> = <span class="ruby-identifier">files</span>.<span class="ruby-identifier">first</span>
|
|
1038
|
+
<span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
|
1039
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file</span>.<span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>)) <span class="ruby-operator"><</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">latest_file</span>.<span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>))
|
|
1040
|
+
<span class="ruby-identifier">latest_file</span> = <span class="ruby-identifier">file</span>
|
|
1041
|
+
<span class="ruby-keyword">end</span>
|
|
1042
|
+
<span class="ruby-keyword">end</span>
|
|
1043
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">latest_file</span>
|
|
1044
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1045
|
+
</div>
|
|
1046
|
+
</div>
|
|
1047
|
+
|
|
1048
|
+
</div>
|
|
1049
|
+
|
|
1050
|
+
<div class="method">
|
|
1051
|
+
<div class="title method-title" id="method-i-give_me_recent_file">
|
|
1052
|
+
|
|
1053
|
+
<b>give_me_recent_file</b>(files)
|
|
1054
|
+
|
|
1055
|
+
<a href="../classes/SelBackup.html#method-i-give_me_recent_file" name="method-i-give_me_recent_file" class="permalink">Link</a>
|
|
1056
|
+
</div>
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
<div class="description">
|
|
1060
|
+
<p>Public: returns most recent file</p>
|
|
1061
|
+
|
|
1062
|
+
<p>files: array of AWS object file</p>
|
|
1063
|
+
|
|
1064
|
+
<p>Returns the most recent file, based on the date</p>
|
|
1065
|
+
</div>
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
<div class="sourcecode">
|
|
1073
|
+
|
|
1074
|
+
<p class="source-link">
|
|
1075
|
+
Source:
|
|
1076
|
+
<a href="javascript:toggleSource('method-i-give_me_recent_file_source')" id="l_method-i-give_me_recent_file_source">show</a>
|
|
1077
|
+
|
|
1078
|
+
</p>
|
|
1079
|
+
<div id="method-i-give_me_recent_file_source" class="dyn-source">
|
|
1080
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 222</span>
|
|
1081
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">give_me_recent_file</span>(<span class="ruby-identifier">files</span>)
|
|
1082
|
+
<span class="ruby-identifier">recent_file</span> = <span class="ruby-identifier">files</span>.<span class="ruby-identifier">first</span>
|
|
1083
|
+
<span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">file</span> <span class="ruby-operator">|</span>
|
|
1084
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file</span>.<span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>)) <span class="ruby-operator">></span> <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">recent_file</span>.<span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>))
|
|
1085
|
+
<span class="ruby-identifier">recent_file</span> = <span class="ruby-identifier">file</span>
|
|
1086
|
+
<span class="ruby-keyword">end</span>
|
|
1087
|
+
<span class="ruby-keyword">end</span>
|
|
1088
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">recent_file</span>
|
|
1089
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1090
|
+
</div>
|
|
1091
|
+
</div>
|
|
1092
|
+
|
|
1093
|
+
</div>
|
|
1094
|
+
|
|
1095
|
+
<div class="method">
|
|
1096
|
+
<div class="title method-title" id="method-i-monthly_good-3F">
|
|
1097
|
+
|
|
1098
|
+
<b>monthly_good?</b>(files, nb_month)
|
|
1099
|
+
|
|
1100
|
+
<a href="../classes/SelBackup.html#method-i-monthly_good-3F" name="method-i-monthly_good-3F" class="permalink">Link</a>
|
|
1101
|
+
</div>
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
<div class="description">
|
|
1105
|
+
<p>Public: Check monthly files number</p>
|
|
1106
|
+
<dl class="rdoc-list note-list"><dt>files
|
|
1107
|
+
<dd>
|
|
1108
|
+
<p>Array of monthly files</p>
|
|
1109
|
+
</dd></dl>
|
|
1110
|
+
|
|
1111
|
+
<pre>['file/2013-01-01-monthly-file.tgz', 'file/2013-01-02-monthly-file.tgz', ...]</pre>
|
|
1112
|
+
|
|
1113
|
+
<p>Returns false if there is more than 3 monthly files. False in other cases</p>
|
|
1114
|
+
</div>
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
<div class="sourcecode">
|
|
1122
|
+
|
|
1123
|
+
<p class="source-link">
|
|
1124
|
+
Source:
|
|
1125
|
+
<a href="javascript:toggleSource('method-i-monthly_good-3F_source')" id="l_method-i-monthly_good-3F_source">show</a>
|
|
1126
|
+
|
|
1127
|
+
</p>
|
|
1128
|
+
<div id="method-i-monthly_good-3F_source" class="dyn-source">
|
|
1129
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 239</span>
|
|
1130
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">monthly_good?</span>(<span class="ruby-identifier">files</span>, <span class="ruby-identifier">nb_month</span>)
|
|
1131
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">files</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-identifier">nb_month</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
|
|
1132
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1133
|
+
</div>
|
|
1134
|
+
</div>
|
|
1135
|
+
|
|
1136
|
+
</div>
|
|
1137
|
+
|
|
1138
|
+
<div class="method">
|
|
1139
|
+
<div class="title method-title" id="method-i-push_file">
|
|
1140
|
+
|
|
1141
|
+
<b>push_file</b>(file)
|
|
1142
|
+
|
|
1143
|
+
<a href="../classes/SelBackup.html#method-i-push_file" name="method-i-push_file" class="permalink">Link</a>
|
|
1144
|
+
</div>
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
<div class="description">
|
|
1148
|
+
<p>Public: pushes a file to s3 server</p>
|
|
1149
|
+
<dl class="rdoc-list note-list"><dt>file
|
|
1150
|
+
<dd>
|
|
1151
|
+
<p>hash containing the key and the body of the file you want to upload</p>
|
|
1152
|
+
</dd></dl>
|
|
1153
|
+
|
|
1154
|
+
<p>Returns nothing</p>
|
|
1155
|
+
</div>
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
<div class="sourcecode">
|
|
1163
|
+
|
|
1164
|
+
<p class="source-link">
|
|
1165
|
+
Source:
|
|
1166
|
+
<a href="javascript:toggleSource('method-i-push_file_source')" id="l_method-i-push_file_source">show</a>
|
|
1167
|
+
|
|
1168
|
+
</p>
|
|
1169
|
+
<div id="method-i-push_file_source" class="dyn-source">
|
|
1170
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 298</span>
|
|
1171
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">push_file</span>(<span class="ruby-identifier">file</span>)
|
|
1172
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/[\w+.-]+\/[\w+.-]+-\d{4}-\d{2}-\d{2}-[\w+.-]+/</span>
|
|
1173
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">'/'</span>).<span class="ruby-identifier">first</span>
|
|
1174
|
+
<span class="ruby-identifier">name_parts</span> = <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">'/'</span>).<span class="ruby-identifier">last</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'-'</span>)
|
|
1175
|
+
<span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>] = <span class="ruby-node">"#{filename}/#{name_parts[1]}-#{name_parts[2]}-#{name_parts[3]}-#{name_parts[0]}-#{filename}"</span>
|
|
1176
|
+
<span class="ruby-keyword">end</span>
|
|
1177
|
+
<span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">files</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">key</span><span class="ruby-operator">:</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:key</span>], <span class="ruby-identifier">body</span><span class="ruby-operator">:</span> <span class="ruby-identifier">file</span>[<span class="ruby-value">:body</span>])
|
|
1178
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1179
|
+
</div>
|
|
1180
|
+
</div>
|
|
1181
|
+
|
|
1182
|
+
</div>
|
|
1183
|
+
|
|
1184
|
+
<div class="method">
|
|
1185
|
+
<div class="title method-title" id="method-i-should_monthly-3F">
|
|
1186
|
+
|
|
1187
|
+
<b>should_monthly?</b>(file1, file2)
|
|
1188
|
+
|
|
1189
|
+
<a href="../classes/SelBackup.html#method-i-should_monthly-3F" name="method-i-should_monthly-3F" class="permalink">Link</a>
|
|
1190
|
+
</div>
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
<div class="description">
|
|
1194
|
+
<p>Public: date diff</p>
|
|
1195
|
+
<dl class="rdoc-list note-list"><dt>file1
|
|
1196
|
+
<dd>
|
|
1197
|
+
<p>latest weekly file</p>
|
|
1198
|
+
</dd><dt>file2
|
|
1199
|
+
<dd>
|
|
1200
|
+
<p>most recent monthly file</p>
|
|
1201
|
+
</dd></dl>
|
|
1202
|
+
|
|
1203
|
+
<p>Returns true if datediff between the two files is upper than 1 month. False
|
|
1204
|
+
in other cases</p>
|
|
1205
|
+
</div>
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
<div class="sourcecode">
|
|
1213
|
+
|
|
1214
|
+
<p class="source-link">
|
|
1215
|
+
Source:
|
|
1216
|
+
<a href="javascript:toggleSource('method-i-should_monthly-3F_source')" id="l_method-i-should_monthly-3F_source">show</a>
|
|
1217
|
+
|
|
1218
|
+
</p>
|
|
1219
|
+
<div id="method-i-should_monthly-3F_source" class="dyn-source">
|
|
1220
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 335</span>
|
|
1221
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">should_monthly?</span>(<span class="ruby-identifier">file1</span>, <span class="ruby-identifier">file2</span>)
|
|
1222
|
+
<span class="ruby-keyword">begin</span>
|
|
1223
|
+
<span class="ruby-identifier">date1</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file1</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>)).<span class="ruby-identifier">prev_month</span>
|
|
1224
|
+
<span class="ruby-identifier">date2</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file2</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>))
|
|
1225
|
+
<span class="ruby-keyword">rescue</span>
|
|
1226
|
+
<span class="ruby-identifier">print</span> <span class="ruby-string">"Wrong date (Date.parse in should_monthly)."</span>
|
|
1227
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
|
1228
|
+
<span class="ruby-keyword">end</span>
|
|
1229
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">date1</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">date2</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
|
|
1230
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1231
|
+
</div>
|
|
1232
|
+
</div>
|
|
1233
|
+
|
|
1234
|
+
</div>
|
|
1235
|
+
|
|
1236
|
+
<div class="method">
|
|
1237
|
+
<div class="title method-title" id="method-i-should_weekly-3F">
|
|
1238
|
+
|
|
1239
|
+
<b>should_weekly?</b>(file1, file2)
|
|
1240
|
+
|
|
1241
|
+
<a href="../classes/SelBackup.html#method-i-should_weekly-3F" name="method-i-should_weekly-3F" class="permalink">Link</a>
|
|
1242
|
+
</div>
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
<div class="description">
|
|
1246
|
+
<p>Public: date diff</p>
|
|
1247
|
+
<dl class="rdoc-list note-list"><dt>file1
|
|
1248
|
+
<dd>
|
|
1249
|
+
<p>latest daily file</p>
|
|
1250
|
+
</dd><dt>file2
|
|
1251
|
+
<dd>
|
|
1252
|
+
<p>most recent weekly file</p>
|
|
1253
|
+
</dd></dl>
|
|
1254
|
+
|
|
1255
|
+
<p>Returns true if datediff between the two files is upper than 7 days. False
|
|
1256
|
+
in other cases</p>
|
|
1257
|
+
</div>
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
<div class="sourcecode">
|
|
1265
|
+
|
|
1266
|
+
<p class="source-link">
|
|
1267
|
+
Source:
|
|
1268
|
+
<a href="javascript:toggleSource('method-i-should_weekly-3F_source')" id="l_method-i-should_weekly-3F_source">show</a>
|
|
1269
|
+
|
|
1270
|
+
</p>
|
|
1271
|
+
<div id="method-i-should_weekly-3F_source" class="dyn-source">
|
|
1272
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 315</span>
|
|
1273
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">should_weekly?</span>(<span class="ruby-identifier">file1</span>, <span class="ruby-identifier">file2</span>)
|
|
1274
|
+
<span class="ruby-keyword">begin</span>
|
|
1275
|
+
<span class="ruby-identifier">date1</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file1</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>))
|
|
1276
|
+
<span class="ruby-identifier">date2</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">file2</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'-'</span>, <span class="ruby-string">''</span>))
|
|
1277
|
+
<span class="ruby-keyword">rescue</span>
|
|
1278
|
+
<span class="ruby-identifier">print</span> <span class="ruby-string">"Wrong date (Date.parse in should_monthly)."</span>
|
|
1279
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
|
1280
|
+
<span class="ruby-keyword">end</span>
|
|
1281
|
+
<span class="ruby-identifier">date_diff</span> = <span class="ruby-identifier">date1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">date2</span>
|
|
1282
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">date_diff</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">>=</span> <span class="ruby-number">7</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>
|
|
1283
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1284
|
+
</div>
|
|
1285
|
+
</div>
|
|
1286
|
+
|
|
1287
|
+
</div>
|
|
1288
|
+
|
|
1289
|
+
<div class="method">
|
|
1290
|
+
<div class="title method-title" id="method-i-upload_file">
|
|
1291
|
+
|
|
1292
|
+
<b>upload_file</b>(file, nb_day = 7, nb_week = 4, nb_month = 3)
|
|
1293
|
+
|
|
1294
|
+
<a href="../classes/SelBackup.html#method-i-upload_file" name="method-i-upload_file" class="permalink">Link</a>
|
|
1295
|
+
</div>
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
<div class="description">
|
|
1299
|
+
<p>Public: upload file algorythm</p>
|
|
1300
|
+
<dl class="rdoc-list note-list"><dt>file
|
|
1301
|
+
<dd>
|
|
1302
|
+
<p>file you want to upload</p>
|
|
1303
|
+
</dd></dl>
|
|
1304
|
+
|
|
1305
|
+
<p>Uploads file as daily file and check daily, weekly and monthly full.</p>
|
|
1306
|
+
|
|
1307
|
+
<p>Returns nothing</p>
|
|
1308
|
+
</div>
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
<div class="sourcecode">
|
|
1316
|
+
|
|
1317
|
+
<p class="source-link">
|
|
1318
|
+
Source:
|
|
1319
|
+
<a href="javascript:toggleSource('method-i-upload_file_source')" id="l_method-i-upload_file_source">show</a>
|
|
1320
|
+
|
|
1321
|
+
</p>
|
|
1322
|
+
<div id="method-i-upload_file_source" class="dyn-source">
|
|
1323
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 353</span>
|
|
1324
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">upload_file</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">nb_day</span> = <span class="ruby-number">7</span>, <span class="ruby-identifier">nb_week</span> = <span class="ruby-number">4</span>, <span class="ruby-identifier">nb_month</span> = <span class="ruby-number">3</span>)
|
|
1325
|
+
<span class="ruby-identifier">daily_file</span> = <span class="ruby-identifier">gen_daily_file</span>(<span class="ruby-identifier">file</span>)
|
|
1326
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">daily_file</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">false</span>
|
|
1327
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
|
1328
|
+
<span class="ruby-keyword">end</span>
|
|
1329
|
+
<span class="ruby-identifier">push_file</span>(<span class="ruby-identifier">daily_file</span>)
|
|
1330
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">check_daily</span>(<span class="ruby-identifier">daily_file</span>[<span class="ruby-value">:myname</span>], <span class="ruby-identifier">nb_day</span>)
|
|
1331
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">check_weekly</span>(<span class="ruby-identifier">daily_file</span>[<span class="ruby-value">:myname</span>], <span class="ruby-identifier">nb_week</span>)
|
|
1332
|
+
<span class="ruby-identifier">check_monthly</span>(<span class="ruby-identifier">daily_file</span>[<span class="ruby-value">:myname</span>], <span class="ruby-identifier">nb_month</span>)
|
|
1333
|
+
<span class="ruby-keyword">end</span>
|
|
1334
|
+
<span class="ruby-keyword">end</span>
|
|
1335
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1336
|
+
</div>
|
|
1337
|
+
</div>
|
|
1338
|
+
|
|
1339
|
+
</div>
|
|
1340
|
+
|
|
1341
|
+
<div class="method">
|
|
1342
|
+
<div class="title method-title" id="method-i-weekly_good-3F">
|
|
1343
|
+
|
|
1344
|
+
<b>weekly_good?</b>(directoryFiles, nb_week)
|
|
1345
|
+
|
|
1346
|
+
<a href="../classes/SelBackup.html#method-i-weekly_good-3F" name="method-i-weekly_good-3F" class="permalink">Link</a>
|
|
1347
|
+
</div>
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
<div class="description">
|
|
1351
|
+
<p>Public: Check weekly files number</p>
|
|
1352
|
+
<dl class="rdoc-list note-list"><dt>files
|
|
1353
|
+
<dd>
|
|
1354
|
+
<p>Array of daily files</p>
|
|
1355
|
+
</dd></dl>
|
|
1356
|
+
|
|
1357
|
+
<pre>['file/2013-01-01-weekly-file.tgz', 'file/013-01-02-weekly-2file.tgz', ...]</pre>
|
|
1358
|
+
|
|
1359
|
+
<p>Returns false if there is more than 4 weekly files. False in other cases</p>
|
|
1360
|
+
</div>
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
<div class="sourcecode">
|
|
1368
|
+
|
|
1369
|
+
<p class="source-link">
|
|
1370
|
+
Source:
|
|
1371
|
+
<a href="javascript:toggleSource('method-i-weekly_good-3F_source')" id="l_method-i-weekly_good-3F_source">show</a>
|
|
1372
|
+
|
|
1373
|
+
</p>
|
|
1374
|
+
<div id="method-i-weekly_good-3F_source" class="dyn-source">
|
|
1375
|
+
<pre><span class="ruby-comment"># File lib/selbackup.rb, line 373</span>
|
|
1376
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">weekly_good?</span>(<span class="ruby-identifier">directoryFiles</span>, <span class="ruby-identifier">nb_week</span>)
|
|
1377
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">directoryFiles</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-identifier">nb_week</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>
|
|
1378
|
+
<span class="ruby-keyword">end</span></pre>
|
|
1379
|
+
</div>
|
|
1380
|
+
</div>
|
|
1381
|
+
|
|
1382
|
+
</div>
|
|
1383
|
+
</div>
|
|
1384
|
+
|
|
1385
|
+
</div>
|
|
1386
|
+
</body>
|
|
1387
|
+
</html>
|