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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +48 -0
  4. data/LICENSE +14 -0
  5. data/README.fr.md +82 -0
  6. data/README.md +83 -0
  7. data/Rakefile +26 -0
  8. data/doc/apple-touch-icon.png +0 -0
  9. data/doc/classes/Object.html +121 -0
  10. data/doc/classes/SelBackup.html +1387 -0
  11. data/doc/created.rid +6 -0
  12. data/doc/css/github.css +129 -0
  13. data/doc/css/main.css +333 -0
  14. data/doc/css/panel.css +384 -0
  15. data/doc/css/reset.css +48 -0
  16. data/doc/favicon.ico +0 -0
  17. data/doc/files/Gemfile.html +84 -0
  18. data/doc/files/Guardfile.html +147 -0
  19. data/doc/files/LICENSE.html +86 -0
  20. data/doc/files/Rakefile.html +101 -0
  21. data/doc/files/backup-to-s3_rb.html +85 -0
  22. data/doc/files/lib/selbackup_rb.html +89 -0
  23. data/doc/files/lib-backup_rb.html +89 -0
  24. data/doc/files/mv_files_rb.html +89 -0
  25. data/doc/files/spec/selbackup_spec_rb.html +76 -0
  26. data/doc/files/test/lib-backup_test_rb.html +76 -0
  27. data/doc/i/arrows.png +0 -0
  28. data/doc/i/results_bg.png +0 -0
  29. data/doc/i/tree_bg.png +0 -0
  30. data/doc/index.html +13 -0
  31. data/doc/js/highlight.pack.js +1 -0
  32. data/doc/js/jquery-1.3.2.min.js +19 -0
  33. data/doc/js/jquery-effect.js +593 -0
  34. data/doc/js/main.js +24 -0
  35. data/doc/js/navigation.js +142 -0
  36. data/doc/js/search_index.js +1 -0
  37. data/doc/js/searchdoc.js +449 -0
  38. data/doc/js/searcher.js +228 -0
  39. data/doc/panel/index.html +73 -0
  40. data/doc/panel/links.html +16 -0
  41. data/doc/panel/tree.js +1 -0
  42. data/lib/selbackup.rb +376 -0
  43. data/selbackup.gemspec +13 -0
  44. data/spec/selbackup_spec.rb +240 -0
  45. data/upload_test/create_files.sh +13 -0
  46. metadata +88 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8dedce289864dd69d16c75eadaf37e8c93c68b85
4
+ data.tar.gz: 2dbe40fcf8cfed04800806f986716df513097043
5
+ SHA512:
6
+ metadata.gz: 46a1950613a07676a523cd897a714e64a8a034eecb298702d7bc8b1c50d7fb1dd64ee49b6b6265f413b43bf218bc73fb73c54e33f3ba3da7defc3efbb1e42fdb
7
+ data.tar.gz: 69ac7b8b16af1bcd1b7a046b95af2e11fdac066e2d6af80ddc3747185e9588cacb1ff43b581482370cc14c4423e7b70ef3fbfaaee19f78cf732788b4b7bc6f5e
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'active_support'
4
+ gem 'fog'
5
+ gem 'i18n'
6
+ gem 'rake'
7
+
8
+ group :development do
9
+ gem 'rspec'
10
+ gem 'rspec-mocks'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ active_support (3.0.0)
5
+ activesupport (= 3.0.0)
6
+ activesupport (3.0.0)
7
+ builder (3.2.2)
8
+ diff-lcs (1.2.4)
9
+ excon (0.23.0)
10
+ fog (1.12.1)
11
+ builder
12
+ excon (~> 0.23.0)
13
+ formatador (~> 0.2.0)
14
+ mime-types
15
+ multi_json (~> 1.0)
16
+ net-scp (~> 1.1)
17
+ net-ssh (>= 2.1.3)
18
+ nokogiri (~> 1.5.0)
19
+ ruby-hmac
20
+ formatador (0.2.4)
21
+ i18n (0.6.4)
22
+ mime-types (1.23)
23
+ multi_json (1.7.7)
24
+ net-scp (1.1.2)
25
+ net-ssh (>= 2.6.5)
26
+ net-ssh (2.6.8)
27
+ nokogiri (1.5.10)
28
+ rake (10.1.0)
29
+ rspec (2.14.1)
30
+ rspec-core (~> 2.14.0)
31
+ rspec-expectations (~> 2.14.0)
32
+ rspec-mocks (~> 2.14.0)
33
+ rspec-core (2.14.3)
34
+ rspec-expectations (2.14.0)
35
+ diff-lcs (>= 1.1.3, < 2.0)
36
+ rspec-mocks (2.14.1)
37
+ ruby-hmac (0.4.0)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ active_support
44
+ fog
45
+ i18n
46
+ rake
47
+ rspec
48
+ rspec-mocks
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+
data/README.fr.md ADDED
@@ -0,0 +1,82 @@
1
+ # SelBackup
2
+
3
+ Selbackup permet d'uploader facilement des fichiers sur un serveur Amazon S3.
4
+ Selbackup permet également d'avoir un backup d'un même fichier sur une durée personnalisable, sans surcharger le serveur.
5
+
6
+ ## Installation
7
+
8
+ Installation
9
+ ```
10
+ gem install specific_install
11
+ gem specific_install -l https://github.com/Selectra-Dev/selbackup.git
12
+ ```
13
+
14
+ votre_fichier.rb
15
+ ```
16
+ require 'selbackup'
17
+ ```
18
+
19
+ ## Utilisation
20
+
21
+ ```
22
+ selbackup = SelBackup.new('key', 'secret', 'bucket', 'region')
23
+ selbackup.upload_file(VotreFichier, nb_jour, nb_semaine, nb_mois)
24
+ ```
25
+ Key, secret et bucket sont vos identifiants de connection à votre server Amazon S3.
26
+ nb_jour, nb_semaine et nb_mois permet de choisir le nombre de fichier quotidiens, hebdomadaires et mensuels à garder. Ces paramètres sont optionnels et fixés respectivement à 7, 4 et 3 par défaut.
27
+
28
+ ## Backup Rotation System
29
+
30
+ Il vous est possible d'uploader de nombreux type de fichiers, la syntaxe de nommage de fichier recommandée étant: `AAAA-MM-JJ-nom_du_fichier.extension`
31
+ Il est cependant possible de ne pas renseigner de date (la date du jour sera automatiquement rajoutée), ou d'extension.
32
+ A noter que si le fichier à uploader ne contient qu'une date (par exemple, '2013-01-01' ou '2013-01-01.tgz'), une erreur sera retournée et l'upload n'aura pas lieu.
33
+
34
+ SelBackup doit être utilisé chaque jour pour une efficacité optimale.
35
+ Il garde 'nb_jours' versions quotidiennes, 'nb_semaine' versions hebdomadaires et 'nb_mois' versions mensuelles d'un même fichier
36
+
37
+ Ainsi, la rotation des fichiers se fait de cette manière:
38
+ - Chaque jour, un fichier est upload
39
+ - Chaque jour, la plus ancienne version quotidienne est supprimée s'il y a plus de nb_jours fichiers quotidiens
40
+ - Chaque semaine, la plus ancienne version quotidienne devient une version hebdomadaire
41
+ - Chaque semaine, la plus ancienne version hebdomadaire est est supprimée s'il y a plus de nb_semaine fichiers hebdomadaires.
42
+ - Chaque mois, la plus ancienne version hebdomadaire devient une version mensuelle
43
+ - Chaque mois, la plus ancienne version mensuelle est supprimée s'il y a plus de nb_mois fichiers mensuels.
44
+
45
+ Avec les paramètres par défaut, pour un fichier "file1.tgz", l'arborescence de votre serveur S3 ressemblera donc à:
46
+ ```
47
+ bucket/
48
+ file1.tgz/
49
+ 2013-01-01-monthly-file1.tgz # 3 dernières versions mensuelles
50
+ 2013-02-01-monthly-file1.tgz
51
+ 2013-03-01-monthly-file1.tgz
52
+ 2013-03-08-weekly-file1.tgz # 4 dernières versions hebdomadaires
53
+ 2013-03-15-weekly-file1.tgz
54
+ 2013-03-22-weekly-file1.tgz
55
+ 2013-03-29-weekly-file1.tgz
56
+ 2013-04-05-daily-file1.tgz # 7 dernières versions journalières
57
+ 2013-04-06-daily-file1.tgz
58
+ 2013-04-07-daily-file1.tgz
59
+ 2013-04-08-daily-file1.tgz
60
+ 2013-04-09-daily-file1.tgz
61
+
62
+ file2.tgz/
63
+ [...]
64
+ [...]
65
+ ```
66
+
67
+
68
+ ## Auteur
69
+
70
+ Simon Ninon pour Selectra SARL aka [Cylix](https://github.com/Cylix)
71
+
72
+ ## License
73
+
74
+ Nous utilisons la [Licence WTF](LICENSE)
75
+
76
+ ## Contribuer
77
+
78
+ 1. Forkez
79
+ 2. Créez votre branche (`git checkout -b ma-branche`)
80
+ 3. Commit vos changements (`git commit -am 'Nouvelles features'`)
81
+ 4. Push (`git push origin ma-branche`)
82
+ 5. Faîtes une `Pull request`
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # SelBackup
2
+
3
+ Selbackup allows user to upload easily some files on an Amazon S3 server.
4
+ It also integrates a "Rotation backup system", which is very useful to get a backup of a file during a selected period (without it overcharges the server)
5
+
6
+ ## Installation
7
+
8
+ Installation
9
+ ```
10
+ gem install specific_install
11
+ gem specific_install -l https://github.com/Selectra-Dev/selbackup.git
12
+ ```
13
+
14
+ your_file.rb
15
+ ```
16
+ require 'selbackup'
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ selbackup = SelBackup.new('key', 'secret', 'bucket', 'region')
23
+ selbackup.upload_file(VotreFichier, nb_day, nb_week, nb_month)
24
+ ```
25
+ Key, secret et bucket are your Amazon S3 logins.
26
+ nb_day, nb_week and nb_month allow user to choose the number of daily, weekly and monthly files to keep on the server. These parameters are optionnal and are set, by default, to 7, 4 and 3.
27
+
28
+ ## Backup Rotation System
29
+
30
+ You can upload a lot of different files.
31
+ Recommended naming convention is: `YYYY-MM-DD-filename.extension`, but you can upload files named differently.
32
+ For example, you can upload a file without date (today's date will be set by default), or a file without extension.
33
+ However, note that trying to upload a file whose name contains only a date (like '2013-01-01' or '2013-01-01.tgz') will return an error and the upload won't happened.
34
+
35
+ Selbackup should be used every day to maximize performance.
36
+ It keeps 'nb_day' daily versions, 'nb_week' weekly_version and 'nb_month' monthly version of a same file.
37
+
38
+ Thus, the files rotation will proceed like this:
39
+ - Each day, a file is upload
40
+ - Each day, the latest daily version is removed if there are more than 'nb_days' daily file versions
41
+ - Each week, the latest daily version upgrades to weekly version.
42
+ - Each week, the latest weekly version is removed if there are more than 'nb_week' weekly file versions
43
+ - Each month, the latest weekly version upgrades to monthly version
44
+ - Each month, the latest monthly version is removed if there are more than 'nb_month' monthly file versions
45
+
46
+ With default parameters, for a "file1.tgz" file, the tree server will looks like the following scheme
47
+ ```
48
+ bucket/
49
+ file1.tgz/
50
+ 2013-01-01-monthly-file1.tgz # 3 last monthly versions
51
+ 2013-02-01-monthly-file1.tgz
52
+ 2013-03-01-monthly-file1.tgz
53
+ 2013-03-08-weekly-file1.tgz # 4 last weekly versions
54
+ 2013-03-15-weekly-file1.tgz
55
+ 2013-03-22-weekly-file1.tgz
56
+ 2013-03-29-weekly-file1.tgz
57
+ 2013-04-05-daily-file1.tgz # 7 last daily versions
58
+ 2013-04-06-daily-file1.tgz
59
+ 2013-04-07-daily-file1.tgz
60
+ 2013-04-08-daily-file1.tgz
61
+ 2013-04-09-daily-file1.tgz
62
+
63
+ file2.tgz/
64
+ [...]
65
+ [...]
66
+ ```
67
+
68
+
69
+ ## Author
70
+
71
+ Simon Ninon for Selectra SARL aka [Cylix](https://github.com/Cylix)
72
+
73
+ ## License
74
+
75
+ We are using [WTF License](LICENSE)
76
+
77
+ ## Contribute
78
+
79
+ 1. Fork
80
+ 2. Create your branch (`git checkout -b my-branch`)
81
+ 3. Commit your new features (`git commit -am 'New features'`)
82
+ 4. Push (`git push origin my-branch`)
83
+ 5. Make a `Pull request`
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rspec/core/rake_task'
2
+ require './lib/selbackup.rb'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :test_upload do
9
+ if ENV["key"] && ENV["secret"] && ENV["bucket"]
10
+ key = ENV["key"]
11
+ secret = ENV["secret"]
12
+ bucket = ENV["bucket"]
13
+
14
+ `mkdir upload_test/tmp`
15
+ `bash upload_test/create_files.sh`
16
+ sb = SelBackup.new(key, secret, bucket)
17
+ files = Dir.glob("upload_test/tmp/*")
18
+ files.each do | file |
19
+ puts "Uploading: #{file}"
20
+ sb.upload_file(file)
21
+ `rm #{file}`
22
+ end
23
+ else
24
+ puts "Usage: rake test_upload key='...' secret='...' bucket='...'"
25
+ end
26
+ end
Binary file
@@ -0,0 +1,121 @@
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>Object</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
+ Object
24
+
25
+ <span class="parent">&lt;
26
+
27
+ BasicObject
28
+
29
+ </span>
30
+
31
+ </h1>
32
+ <ul class="files">
33
+
34
+ <li><a href="../files/backup-to-s3_rb.html">backup-to-s3.rb</a></li>
35
+
36
+ </ul>
37
+ </div>
38
+ <div id="bodyContent">
39
+ <div id="content">
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+ <!-- Section constants -->
67
+ <div class="sectiontitle">Constants</div>
68
+ <table border='0' cellpadding='5'>
69
+
70
+ <tr valign='top'>
71
+ <td class="attr-name">BACKUP_DIR</td>
72
+ <td>=</td>
73
+ <td class="attr-value">&#39;test/&#39;</td>
74
+ </tr>
75
+
76
+ <tr valign='top'>
77
+ <td>&nbsp;</td>
78
+ <td colspan="2" class="attr-desc"><p>Le principe des sauvegardes est le suivant : Sauvegarde régulière des bases
79
+ de données et des sites dans /home/backups. Lancement régulier de ce
80
+ programme pour pousser les fichiers dans S3 Il ne peux y avoir qu’une seule
81
+ instance a un moment donné</p></td>
82
+ </tr>
83
+
84
+
85
+ <tr valign='top'>
86
+ <td class="attr-name">CMD_PS_AX</td>
87
+ <td>=</td>
88
+ <td class="attr-value">&quot;ps ax | grep &#39;PID&#39; | grep -v grep | awk &#39;{print $1}&#39; | xargs&quot;</td>
89
+ </tr>
90
+
91
+ <tr valign='top'>
92
+ <td>&nbsp;</td>
93
+ <td colspan="2" class="attr-desc"></td>
94
+ </tr>
95
+
96
+
97
+ <tr valign='top'>
98
+ <td class="attr-name">PID_FILE</td>
99
+ <td>=</td>
100
+ <td class="attr-value">&#39;/var/run/backup-selectra.pid&#39;</td>
101
+ </tr>
102
+
103
+ <tr valign='top'>
104
+ <td>&nbsp;</td>
105
+ <td colspan="2" class="attr-desc"></td>
106
+ </tr>
107
+
108
+
109
+ </table>
110
+
111
+
112
+
113
+
114
+
115
+
116
+ <!-- Methods -->
117
+ </div>
118
+
119
+ </div>
120
+ </body>
121
+ </html>