webtranslateit-safe 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +4 -0
  3. data/README.markdown +128 -123
  4. data/bin/webtranslateit-safe +1 -3
  5. data/lib/{webtranslateit → web_translate_it}/safe/cloudfiles.rb +2 -2
  6. data/lib/{webtranslateit → web_translate_it}/safe/config/builder.rb +1 -1
  7. data/lib/{webtranslateit → web_translate_it}/safe/config/node.rb +4 -5
  8. data/lib/{webtranslateit → web_translate_it}/safe/ftp.rb +5 -3
  9. data/lib/{webtranslateit → web_translate_it}/safe/local.rb +2 -2
  10. data/lib/{webtranslateit → web_translate_it}/safe/mongodump.rb +1 -1
  11. data/lib/{webtranslateit → web_translate_it}/safe/s3.rb +4 -2
  12. data/lib/{webtranslateit → web_translate_it}/safe/scp.rb +4 -2
  13. data/lib/{webtranslateit → web_translate_it}/safe/sftp.rb +4 -2
  14. data/lib/{webtranslateit → web_translate_it}/safe/sink.rb +2 -2
  15. data/lib/{webtranslateit → web_translate_it}/safe/tmp_file.rb +0 -1
  16. data/lib/web_translate_it/safe.rb +69 -0
  17. metadata +23 -23
  18. data/lib/webtranslateit/safe.rb +0 -69
  19. /data/lib/{webtranslateit → web_translate_it}/safe/archive.rb +0 -0
  20. /data/lib/{webtranslateit → web_translate_it}/safe/backup.rb +0 -0
  21. /data/lib/{webtranslateit → web_translate_it}/safe/gpg.rb +0 -0
  22. /data/lib/{webtranslateit → web_translate_it}/safe/gzip.rb +0 -0
  23. /data/lib/{webtranslateit → web_translate_it}/safe/mysqldump.rb +0 -0
  24. /data/lib/{webtranslateit → web_translate_it}/safe/pgdump.rb +0 -0
  25. /data/lib/{webtranslateit → web_translate_it}/safe/pipe.rb +0 -0
  26. /data/lib/{webtranslateit → web_translate_it}/safe/source.rb +0 -0
  27. /data/lib/{webtranslateit → web_translate_it}/safe/stream.rb +0 -0
  28. /data/lib/{webtranslateit → web_translate_it}/safe/svndump.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63bd94e905a8a424ce2b408fa3d0d2898fc5d22c3be9739a95ff73668cd612ad
4
- data.tar.gz: 2f33a476839a38aa403e89a3f0e35ad5c78a9c403756c0472f15c45337a0b575
3
+ metadata.gz: b87215e582012cb8e81e826fa3447c65c0b30a36940840d0e49114832c705fff
4
+ data.tar.gz: e93d445482019f3e864599b8df34506463edaf2b2bb864dfee4d3d0b44cb559c
5
5
  SHA512:
6
- metadata.gz: b50f77cc5ee6b609ad05e85fa5fc106ed21af49e014397427aa9a77de4bba9e5d6e3cff8773d78e14314e44388d6f0cf6cbf258d0e3ffd9db0ddeedc063a525d
7
- data.tar.gz: e21c75b914bf576842f22893098c872659ba5d7dd27b84d4f087226e7aa80a43f32a133f668a20c09492762f2459707ae1c3e7f9e074db4a8b9fc7c933b4f885
6
+ metadata.gz: '08678656aeb78fdd500dd26209ac86859517e2a828773b2ec0c9e2d9b3262b0e322c5a75618029cd49566d60a11f69861336c63101a9b42230bece81a3ffce50'
7
+ data.tar.gz: dcb82c4237e64d83393bc22de543dd6ba599abae7dbb0a57202dce73ef112da0e59f8a2fac7b6f1016dfcb91430fc7ada1da6cac160c7917f33992c85be0d623
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.6 - 2023-06-30
2
+
3
+ * Code refactoring.
4
+
1
5
  ## 0.4.5 - 2023-06-30
2
6
 
3
7
  * Add SCP backup strategy.
data/README.markdown CHANGED
@@ -83,7 +83,7 @@ We recommend also pringing the hard paper copy of your GPG key 'just in case'.
83
83
 
84
84
  The procedure to create and transfer the key is as follows:
85
85
 
86
- 1. run 'gpg --gen-key' on your local machine and follow onscreen instructions to create the key
86
+ 1. run `gpg --gen-key` on your local machine and follow onscreen instructions to create the key
87
87
  (you can accept all the defaults).
88
88
 
89
89
  2. extract your public key into a file (assuming you used test@example.com as your key email):
@@ -94,143 +94,148 @@ The procedure to create and transfer the key is as follows:
94
94
 
95
95
  4. import public key on the remote system:
96
96
 
97
- $ gpg --import test@example.com.pub
98
- gpg: key 45CA9403: public key "Test Backup <test@example.com>" imported
99
- gpg: Total number processed: 1
100
- gpg: imported: 1
97
+ ``` bash
98
+ $ gpg --import test@example.com.pub
99
+ gpg: key 45CA9403: public key "Test Backup <test@example.com>" imported
100
+ gpg: Total number processed: 1
101
+ gpg: imported: 1
102
+ ```
101
103
 
102
104
  5. since we don't keep the secret part of the key on the remote server, gpg has
103
105
  no way to know its yours and can be trusted.
104
106
  To fix that we can sign it with other trusted key, or just directly modify its
105
107
  trust level in gpg (use level 5):
106
108
 
107
- $ gpg --edit-key test@example.com
108
- ...
109
- Command> trust
110
- ...
111
- 1 = I don't know or won't say
112
- 2 = I do NOT trust
113
- 3 = I trust marginally
114
- 4 = I trust fully
115
- 5 = I trust ultimately
116
- m = back to the main menu
117
-
118
- Your decision? 5
119
- ...
120
- Command> quit
109
+ ``` bash
110
+ $ gpg --edit-key test@example.com
111
+ ...
112
+ Command> trust
113
+ ...
114
+ 1 = I don't know or won't say
115
+ 2 = I do NOT trust
116
+ 3 = I trust marginally
117
+ 4 = I trust fully
118
+ 5 = I trust ultimately
119
+ m = back to the main menu
120
+
121
+ Your decision? 5
122
+ ...
123
+ Command> quit
124
+ ```
121
125
 
122
126
  6. export your secret key for backup
123
127
  (we recommend to print it on paper and burn to a CD/DVD and store in a safe place):
124
128
 
125
- $ gpg -a --export-secret-key test@example.com > test@example.com.key
129
+ ``` bash
130
+ $ gpg -a --export-secret-key test@example.com > test@example.com.key
131
+ ```
132
+ ## Example configuration
126
133
 
134
+ ``` ruby
135
+ safe do
136
+ verbose true
137
+
138
+ local path: "/backup/:kind/:id"
139
+
140
+ s3 do
141
+ key "...................."
142
+ secret "........................................"
143
+ bucket "backup.astrails.com"
144
+ path "servers/alpha/:kind/:id"
145
+ end
146
+
147
+ cloudfiles do
148
+ user "..........."
149
+ api_key "................................."
150
+ container "safe_backup"
151
+ path ":kind/" # this is default
152
+ service_net false
153
+ end
154
+
155
+ sftp do
156
+ host "sftp.astrails.com"
157
+ user "astrails"
158
+ # port 8023
159
+ password "ssh password for sftp"
160
+ end
161
+
162
+ sftp do
163
+ host "sftp.astrails.com"
164
+ user "astrails"
165
+ # port 8023
166
+ password "ssh password for scp"
167
+ end
168
+
169
+ gpg do
170
+ command "/usr/local/bin/gpg"
171
+ options "--no-use-agent"
172
+ # symmetric encryption key
173
+ # password "qwe"
174
+
175
+ # public GPG key (must be known to GPG, i.e. be on the keyring)
176
+ key "backup@astrails.com"
177
+ end
178
+
179
+ keep do
180
+ local 20
181
+ s3 100
182
+ cloudfiles 100
183
+ sftp 100
184
+ scp 100
185
+ end
186
+
187
+ mysqldump do
188
+ options "-ceKq --single-transaction --create-options"
189
+
190
+ user "root"
191
+ password "............"
192
+ socket "/var/run/mysqld/mysqld.sock"
193
+
194
+ database :blog
195
+ database :servershape
196
+ database :astrails_com
197
+ database :secret_project_com do
198
+ skip_tables "foo"
199
+ skip_tables ["bar", "baz"]
200
+ end
127
201
 
202
+ end
128
203
 
129
- ## Example configuration
204
+ svndump do
205
+ repo :my_repo do
206
+ repo_path "/home/svn/my_repo"
207
+ end
208
+ end
209
+
210
+ pgdump do
211
+ options "-i -x -O" # -i => ignore version, -x => do not dump privileges (grant/revoke), -O => skip restoration of object ownership in plain text format
212
+
213
+ user "username"
214
+ password "............" # shouldn't be used, instead setup ident. Current functionality exports a password env to the shell which pg_dump uses - untested!
215
+
216
+ database :blog
217
+ database :stateofflux_com
218
+ end
219
+
220
+ tar do
221
+ options "-h" # dereference symlinks
222
+ archive "git-repositories", files: "/home/git/repositories"
223
+ archive "dot-configs", files: "/home/*/.[^.]*"
224
+ archive "etc", files: "/etc", exclude: "/etc/puppet/other"
225
+
226
+ archive "blog-astrails-com" do
227
+ files "/var/www/blog.astrails.com/"
228
+ exclude "/var/www/blog.astrails.com/log"
229
+ exclude "/var/www/blog.astrails.com/tmp"
230
+ end
130
231
 
131
- safe do
132
- verbose true
133
-
134
- local :path => "/backup/:kind/:id"
135
-
136
- s3 do
137
- key "...................."
138
- secret "........................................"
139
- bucket "backup.astrails.com"
140
- path "servers/alpha/:kind/:id"
141
- end
142
-
143
- cloudfiles do
144
- user "..........."
145
- api_key "................................."
146
- container "safe_backup"
147
- path ":kind/" # this is default
148
- service_net false
149
- end
150
-
151
- sftp do
152
- host "sftp.astrails.com"
153
- user "astrails"
154
- # port 8023
155
- password "ssh password for sftp"
156
- end
157
-
158
- sftp do
159
- host "sftp.astrails.com"
160
- user "astrails"
161
- # port 8023
162
- password "ssh password for scp"
163
- end
164
-
165
- gpg do
166
- command "/usr/local/bin/gpg"
167
- options "--no-use-agent"
168
- # symmetric encryption key
169
- # password "qwe"
170
-
171
- # public GPG key (must be known to GPG, i.e. be on the keyring)
172
- key "backup@astrails.com"
173
- end
174
-
175
- keep do
176
- local 20
177
- s3 100
178
- cloudfiles 100
179
- sftp 100
180
- scp 100
181
- end
182
-
183
- mysqldump do
184
- options "-ceKq --single-transaction --create-options"
185
-
186
- user "root"
187
- password "............"
188
- socket "/var/run/mysqld/mysqld.sock"
189
-
190
- database :blog
191
- database :servershape
192
- database :astrails_com
193
- database :secret_project_com do
194
- skip_tables "foo"
195
- skip_tables ["bar", "baz"]
196
- end
197
-
198
- end
199
-
200
- svndump do
201
- repo :my_repo do
202
- repo_path "/home/svn/my_repo"
203
- end
204
- end
205
-
206
- pgdump do
207
- options "-i -x -O" # -i => ignore version, -x => do not dump privileges (grant/revoke), -O => skip restoration of object ownership in plain text format
208
-
209
- user "username"
210
- password "............" # shouldn't be used, instead setup ident. Current functionality exports a password env to the shell which pg_dump uses - untested!
211
-
212
- database :blog
213
- database :stateofflux_com
214
- end
215
-
216
- tar do
217
- options "-h" # dereference symlinks
218
- archive "git-repositories", :files => "/home/git/repositories"
219
- archive "dot-configs", :files => "/home/*/.[^.]*"
220
- archive "etc", :files => "/etc", :exclude => "/etc/puppet/other"
221
-
222
- archive "blog-astrails-com" do
223
- files "/var/www/blog.astrails.com/"
224
- exclude "/var/www/blog.astrails.com/log"
225
- exclude "/var/www/blog.astrails.com/tmp"
226
- end
227
-
228
- archive "astrails-com" do
229
- files "/var/www/astrails.com/"
230
- exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
231
- end
232
- end
232
+ archive "astrails-com" do
233
+ files "/var/www/astrails.com/"
234
+ exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
233
235
  end
236
+ end
237
+ end
238
+ ```
234
239
 
235
240
  ## Contributing
236
241
 
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
-
5
3
  require 'webtranslateit/safe'
6
4
 
7
5
  include WebTranslateIt::Safe
@@ -31,7 +29,7 @@ OPTS = [
31
29
  '-n', '--dry-run', '--not-dry-run',
32
30
  '-L', '--local', '--not-local'
33
31
  ].freeze
34
- def main
32
+ def main # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
35
33
  opts = ARGV & OPTS
36
34
  args = ARGV - OPTS
37
35
 
@@ -23,7 +23,7 @@ module WebTranslateIt
23
23
  File.stat(path).size
24
24
  end
25
25
 
26
- def save
26
+ def save # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
27
27
  raise 'pipe-streaming not supported for S3.' unless @backup.path
28
28
 
29
29
  # needed in cleanup even on dry run
@@ -44,7 +44,7 @@ module WebTranslateIt
44
44
  puts("Upload took #{format('%.2f', benchmark)} second(s).") if verbose?
45
45
  end
46
46
 
47
- def cleanup
47
+ def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
48
48
  return if local_only?
49
49
 
50
50
  return unless keep = config[:keep, :cloudfiles]
@@ -42,7 +42,7 @@ module WebTranslateIt
42
42
  end
43
43
  end
44
44
 
45
- def mixed_value(*names)
45
+ def mixed_value(*names) # rubocop:todo Metrics/MethodLength
46
46
  names.each do |m|
47
47
  define_method(m) do |data = {}, &block|
48
48
  ensure_uniq(m)
@@ -1,4 +1,3 @@
1
- require 'webtranslateit/safe/config/builder'
2
1
  module WebTranslateIt
3
2
 
4
3
  module Safe
@@ -9,10 +8,10 @@ module WebTranslateIt
9
8
 
10
9
  attr_reader :parent, :data
11
10
 
12
- def initialize(parent = nil, data = {}, &block)
11
+ def initialize(parent = nil, data = {}, &)
13
12
  @parent = parent
14
13
  @data = {}
15
- merge data, &block
14
+ merge(data, &)
16
15
  end
17
16
 
18
17
  def merge(data = {}, &block)
@@ -47,8 +46,8 @@ module WebTranslateIt
47
46
  end
48
47
  alias []= set
49
48
 
50
- def each(&block)
51
- @data.each(&block)
49
+ def each(&)
50
+ @data.each(&)
52
51
  end
53
52
  include Enumerable
54
53
 
@@ -14,7 +14,7 @@ module WebTranslateIt
14
14
  @path ||= expand(config[:ftp, :path] || config[:local, :path] || ':kind/:id')
15
15
  end
16
16
 
17
- def save
17
+ def save # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
18
18
  raise 'pipe-streaming not supported for FTP.' unless @backup.path
19
19
 
20
20
  puts "Uploading #{host}:#{full_path} via FTP" if verbose? || dry_run?
@@ -35,7 +35,8 @@ module WebTranslateIt
35
35
  puts '...done' if verbose?
36
36
  end
37
37
 
38
- def cleanup
38
+ # rubocop:todo Metrics/PerceivedComplexity
39
+ def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
39
40
  return if local_only? || dry_run?
40
41
 
41
42
  return unless keep = config[:keep, :ftp]
@@ -48,7 +49,7 @@ module WebTranslateIt
48
49
  files = ftp.nlst(path)
49
50
  pattern = File.basename(base.to_s)
50
51
  files = files.select { |x| x.start_with?(pattern) }
51
- puts files.collect { |x| x } if verbose?
52
+ puts(files.collect { |x| x }) if verbose?
52
53
 
53
54
  files = files
54
55
  .collect { |x| x }
@@ -61,6 +62,7 @@ module WebTranslateIt
61
62
  end
62
63
  end
63
64
  end
65
+ # rubocop:enable Metrics/PerceivedComplexity
64
66
 
65
67
  def host
66
68
  config[:ftp, :host]
@@ -16,7 +16,7 @@ module WebTranslateIt
16
16
  @path ||= File.expand_path(expand(config[:local, :path] || raise('missing :local/:path')))
17
17
  end
18
18
 
19
- def save
19
+ def save # rubocop:todo Metrics/AbcSize
20
20
  puts "command: #{@backup.command}" if verbose?
21
21
 
22
22
  # FIXME: probably need to change this to smth like @backup.finalize!
@@ -31,7 +31,7 @@ module WebTranslateIt
31
31
  puts("command took #{format('%.2f', benchmark)} second(s).") if verbose?
32
32
  end
33
33
 
34
- def cleanup
34
+ def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize
35
35
  return unless keep = config[:keep, :local]
36
36
 
37
37
  puts "listing files #{base}" if verbose?
@@ -4,7 +4,7 @@ module WebTranslateIt
4
4
 
5
5
  class Mongodump < Source
6
6
 
7
- def command
7
+ def command # rubocop:todo Metrics/AbcSize
8
8
  opts = []
9
9
  opts << "--host #{config[:host]}" if config[:host]
10
10
  opts << "-u #{config[:user]}" if config[:user]
@@ -16,7 +16,7 @@ module WebTranslateIt
16
16
  @path ||= expand(config[:s3, :path] || config[:local, :path] || ':kind/:id')
17
17
  end
18
18
 
19
- def save
19
+ def save # rubocop:todo Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
20
20
  # FIXME: user friendly error here :)
21
21
  raise 'pipe-streaming not supported for S3.' unless @backup.path
22
22
 
@@ -40,7 +40,8 @@ module WebTranslateIt
40
40
  puts("Upload took #{format('%.2f', benchmark)} second(s).") if verbose?
41
41
  end
42
42
 
43
- def cleanup
43
+ # rubocop:todo Metrics/PerceivedComplexity
44
+ def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
44
45
  return if local_only?
45
46
 
46
47
  return unless keep = config[:keep, :s3]
@@ -58,6 +59,7 @@ module WebTranslateIt
58
59
  AWS::S3::Bucket.objects(bucket, prefix: f)[0].delete unless dry_run? || local_only?
59
60
  end
60
61
  end
62
+ # rubocop:enable Metrics/PerceivedComplexity
61
63
 
62
64
  def bucket
63
65
  config[:s3, :bucket]
@@ -18,7 +18,7 @@ module WebTranslateIt
18
18
  @path ||= expand(config[:scp, :path] || config[:local, :path] || ':kind/:id')
19
19
  end
20
20
 
21
- def save # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
21
+ def save # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
22
22
  raise 'pipe-streaming not supported for SCP.' unless @backup.path
23
23
 
24
24
  puts "Uploading #{host}:#{full_path} via SCP" if verbose? || dry_run?
@@ -60,7 +60,8 @@ module WebTranslateIt
60
60
  puts '...done' if verbose?
61
61
  end
62
62
 
63
- def cleanup
63
+ # rubocop:todo Metrics/PerceivedComplexity
64
+ def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
64
65
  return if local_only? || dry_run?
65
66
 
66
67
  return unless (keep = config[:keep, :scp])
@@ -83,6 +84,7 @@ module WebTranslateIt
83
84
  end
84
85
  end
85
86
  end
87
+ # rubocop:enable Metrics/PerceivedComplexity
86
88
 
87
89
  def host
88
90
  config[:scp, :host]
@@ -16,7 +16,7 @@ module WebTranslateIt
16
16
  @path ||= expand(config[:sftp, :path] || config[:local, :path] || ':kind/:id')
17
17
  end
18
18
 
19
- def save # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
19
+ def save # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
20
20
  raise 'pipe-streaming not supported for SFTP.' unless @backup.path
21
21
 
22
22
  puts "Uploading #{host}:#{full_path} via SFTP" if verbose? || dry_run?
@@ -58,7 +58,8 @@ module WebTranslateIt
58
58
  puts '...done' if verbose?
59
59
  end
60
60
 
61
- def cleanup
61
+ # rubocop:todo Metrics/PerceivedComplexity
62
+ def cleanup # rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/MethodLength
62
63
  return if local_only? || dry_run?
63
64
 
64
65
  return unless keep = config[:keep, :sftp]
@@ -81,6 +82,7 @@ module WebTranslateIt
81
82
  end
82
83
  end
83
84
  end
85
+ # rubocop:enable Metrics/PerceivedComplexity
84
86
 
85
87
  def host
86
88
  config[:sftp, :host]
@@ -25,12 +25,12 @@ module WebTranslateIt
25
25
  end
26
26
 
27
27
  # call block on files to be removed (all except for the LAST 'limit' files
28
- def cleanup_with_limit(files, limit, &block)
28
+ def cleanup_with_limit(files, limit, &)
29
29
  return unless files.size > limit
30
30
 
31
31
  to_remove = files[0..(files.size - limit - 1)]
32
32
  # TODO: validate here
33
- to_remove.each(&block)
33
+ to_remove.each(&)
34
34
  end
35
35
 
36
36
  end
@@ -1,4 +1,3 @@
1
- require 'tmpdir'
2
1
  module WebTranslateIt
3
2
 
4
3
  module Safe
@@ -0,0 +1,69 @@
1
+ require 'aws/s3'
2
+ require 'cloudfiles'
3
+ require 'net/sftp'
4
+ require 'net/scp'
5
+ require 'tmpdir'
6
+ require 'fileutils'
7
+ require 'benchmark'
8
+
9
+ require 'tempfile'
10
+
11
+ require 'web_translate_it/safe/tmp_file'
12
+
13
+ require 'web_translate_it/safe/config/node'
14
+ require 'web_translate_it/safe/config/builder'
15
+
16
+ require 'web_translate_it/safe/stream'
17
+
18
+ require 'web_translate_it/safe/backup'
19
+
20
+ require 'web_translate_it/safe/source'
21
+ require 'web_translate_it/safe/mysqldump'
22
+ require 'web_translate_it/safe/pgdump'
23
+ require 'web_translate_it/safe/archive'
24
+ require 'web_translate_it/safe/svndump'
25
+ require 'web_translate_it/safe/mongodump'
26
+
27
+ require 'web_translate_it/safe/pipe'
28
+ require 'web_translate_it/safe/gpg'
29
+ require 'web_translate_it/safe/gzip'
30
+
31
+ require 'web_translate_it/safe/sink'
32
+ require 'web_translate_it/safe/local'
33
+ require 'web_translate_it/safe/s3'
34
+ require 'web_translate_it/safe/cloudfiles'
35
+ require 'web_translate_it/safe/scp'
36
+ require 'web_translate_it/safe/sftp'
37
+ require 'web_translate_it/safe/ftp'
38
+
39
+ module WebTranslateIt
40
+
41
+ module Safe
42
+
43
+ ROOT = File.join(File.dirname(__FILE__), '..', '..')
44
+
45
+ def safe(&)
46
+ Config::Node.new(&)
47
+ end
48
+
49
+ def process(config)
50
+ [[Mysqldump, %i[mysqldump databases]],
51
+ [Pgdump, %i[pgdump databases]],
52
+ [Mongodump, %i[mongodump databases]],
53
+ [Archive, %i[tar archives]],
54
+ [Svndump, %i[svndump repos]]].each do |klass, path|
55
+ next unless collection = config[*path]
56
+
57
+ collection.each do |name, c|
58
+ klass.new(name, c).backup.run(c, :gpg, :gzip, :local, :s3, :cloudfiles, :scp, :sftp, :ftp)
59
+ end
60
+ end
61
+
62
+ WebTranslateIt::Safe::TmpFile.cleanup
63
+ end
64
+ module_function :safe
65
+ module_function :process
66
+
67
+ end
68
+
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webtranslateit-safe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Briere
@@ -81,28 +81,28 @@ files:
81
81
  - CHANGELOG
82
82
  - README.markdown
83
83
  - bin/webtranslateit-safe
84
- - lib/webtranslateit/safe.rb
85
- - lib/webtranslateit/safe/archive.rb
86
- - lib/webtranslateit/safe/backup.rb
87
- - lib/webtranslateit/safe/cloudfiles.rb
88
- - lib/webtranslateit/safe/config/builder.rb
89
- - lib/webtranslateit/safe/config/node.rb
90
- - lib/webtranslateit/safe/ftp.rb
91
- - lib/webtranslateit/safe/gpg.rb
92
- - lib/webtranslateit/safe/gzip.rb
93
- - lib/webtranslateit/safe/local.rb
94
- - lib/webtranslateit/safe/mongodump.rb
95
- - lib/webtranslateit/safe/mysqldump.rb
96
- - lib/webtranslateit/safe/pgdump.rb
97
- - lib/webtranslateit/safe/pipe.rb
98
- - lib/webtranslateit/safe/s3.rb
99
- - lib/webtranslateit/safe/scp.rb
100
- - lib/webtranslateit/safe/sftp.rb
101
- - lib/webtranslateit/safe/sink.rb
102
- - lib/webtranslateit/safe/source.rb
103
- - lib/webtranslateit/safe/stream.rb
104
- - lib/webtranslateit/safe/svndump.rb
105
- - lib/webtranslateit/safe/tmp_file.rb
84
+ - lib/web_translate_it/safe.rb
85
+ - lib/web_translate_it/safe/archive.rb
86
+ - lib/web_translate_it/safe/backup.rb
87
+ - lib/web_translate_it/safe/cloudfiles.rb
88
+ - lib/web_translate_it/safe/config/builder.rb
89
+ - lib/web_translate_it/safe/config/node.rb
90
+ - lib/web_translate_it/safe/ftp.rb
91
+ - lib/web_translate_it/safe/gpg.rb
92
+ - lib/web_translate_it/safe/gzip.rb
93
+ - lib/web_translate_it/safe/local.rb
94
+ - lib/web_translate_it/safe/mongodump.rb
95
+ - lib/web_translate_it/safe/mysqldump.rb
96
+ - lib/web_translate_it/safe/pgdump.rb
97
+ - lib/web_translate_it/safe/pipe.rb
98
+ - lib/web_translate_it/safe/s3.rb
99
+ - lib/web_translate_it/safe/scp.rb
100
+ - lib/web_translate_it/safe/sftp.rb
101
+ - lib/web_translate_it/safe/sink.rb
102
+ - lib/web_translate_it/safe/source.rb
103
+ - lib/web_translate_it/safe/stream.rb
104
+ - lib/web_translate_it/safe/svndump.rb
105
+ - lib/web_translate_it/safe/tmp_file.rb
106
106
  homepage: http://github.com/webtranslateit/safe
107
107
  licenses:
108
108
  - MIT
@@ -1,69 +0,0 @@
1
- require 'aws/s3'
2
- require 'cloudfiles'
3
- require 'net/sftp'
4
- require 'net/scp'
5
- # require 'net/ftp'
6
- require 'fileutils'
7
- require 'benchmark'
8
-
9
- require 'tempfile'
10
-
11
- require 'webtranslateit/safe/tmp_file'
12
-
13
- require 'webtranslateit/safe/config/node'
14
- require 'webtranslateit/safe/config/builder'
15
-
16
- require 'webtranslateit/safe/stream'
17
-
18
- require 'webtranslateit/safe/backup'
19
-
20
- require 'webtranslateit/safe/source'
21
- require 'webtranslateit/safe/mysqldump'
22
- require 'webtranslateit/safe/pgdump'
23
- require 'webtranslateit/safe/archive'
24
- require 'webtranslateit/safe/svndump'
25
- require 'webtranslateit/safe/mongodump'
26
-
27
- require 'webtranslateit/safe/pipe'
28
- require 'webtranslateit/safe/gpg'
29
- require 'webtranslateit/safe/gzip'
30
-
31
- require 'webtranslateit/safe/sink'
32
- require 'webtranslateit/safe/local'
33
- require 'webtranslateit/safe/s3'
34
- require 'webtranslateit/safe/cloudfiles'
35
- require 'webtranslateit/safe/scp'
36
- require 'webtranslateit/safe/sftp'
37
- require 'webtranslateit/safe/ftp'
38
-
39
- module WebTranslateIt
40
-
41
- module Safe
42
-
43
- ROOT = File.join(File.dirname(__FILE__), '..', '..')
44
-
45
- def safe(&block)
46
- Config::Node.new(&block)
47
- end
48
-
49
- def process(config)
50
- [[Mysqldump, %i[mysqldump databases]],
51
- [Pgdump, %i[pgdump databases]],
52
- [Mongodump, %i[mongodump databases]],
53
- [Archive, %i[tar archives]],
54
- [Svndump, %i[svndump repos]]].each do |klass, path|
55
- next unless collection = config[*path]
56
-
57
- collection.each do |name, c|
58
- klass.new(name, c).backup.run(c, :gpg, :gzip, :local, :s3, :cloudfiles, :scp, :sftp, :ftp)
59
- end
60
- end
61
-
62
- WebTranslateIt::Safe::TmpFile.cleanup
63
- end
64
- module_function :safe
65
- module_function :process
66
-
67
- end
68
-
69
- end