webtranslateit-safe 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +7 -0
- data/README.markdown +133 -161
- data/bin/webtranslateit-safe +2 -4
- data/lib/{webtranslateit → web_translate_it}/safe/cloudfiles.rb +2 -2
- data/lib/{webtranslateit → web_translate_it}/safe/config/builder.rb +1 -1
- data/lib/{webtranslateit → web_translate_it}/safe/config/node.rb +4 -5
- data/lib/{webtranslateit → web_translate_it}/safe/ftp.rb +5 -3
- data/lib/{webtranslateit → web_translate_it}/safe/local.rb +2 -2
- data/lib/{webtranslateit → web_translate_it}/safe/mongodump.rb +1 -1
- data/lib/{webtranslateit → web_translate_it}/safe/s3.rb +4 -2
- data/lib/{webtranslateit → web_translate_it}/safe/scp.rb +4 -2
- data/lib/{webtranslateit → web_translate_it}/safe/sftp.rb +4 -2
- data/lib/{webtranslateit → web_translate_it}/safe/sink.rb +2 -2
- data/lib/{webtranslateit → web_translate_it}/safe/tmp_file.rb +0 -1
- data/lib/web_translate_it/safe.rb +69 -0
- metadata +23 -23
- data/lib/webtranslateit/safe.rb +0 -69
- /data/lib/{webtranslateit → web_translate_it}/safe/archive.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/backup.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/gpg.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/gzip.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/mysqldump.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/pgdump.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/pipe.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/source.rb +0 -0
- /data/lib/{webtranslateit → web_translate_it}/safe/stream.rb +0 -0
- /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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 620a90f70005e6406e8a1d355a90e287ffb38893c1e1ab39ffca0e82707d4122
|
|
4
|
+
data.tar.gz: 52eb2a49cf8aa91cc03c0ee471282e097628487d99ee9f91203b3ed72518f22d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2121d992be6eccad69dcede5b04a7c83a78f156d129d118f49a713d433e0736ead3d8e0185ea5ca9f5650f843e9e7981a619a89cbe1a1f726a84fc1ea0755ab4
|
|
7
|
+
data.tar.gz: 6df61f68e23d994300b155880425f8316744545bba20d13eac1bd1268e97dd0be2a81e7119b935db9a647daafb177398835d081241d10edcb80832ec8ce54a32
|
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
|
@@ -1,39 +1,14 @@
|
|
|
1
1
|
# webtranslateit-safe
|
|
2
2
|
|
|
3
|
-
Simple database and filesystem backups with S3 and Rackspace Cloud Files support (with optional encryption)
|
|
3
|
+
Simple database and filesystem backups with S3 and Rackspace Cloud Files support (with optional encryption).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This is a fork of now abandonned [astrails-safe](https://github.com/astrails/safe) that we’ve been using since 2010. It is now unmaintained and not compatible with ruby 3.2, so we forked it.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
We’ve added:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* simple to install and configure
|
|
13
|
-
* support for simple ‘tar’ backups of directories (with includes/excludes)
|
|
14
|
-
* support for simple mysqldump of mysql databases
|
|
15
|
-
* support for symmetric or public key encryption
|
|
16
|
-
* support for local filesystem, Amazon S3, and Rackspace Cloud Files for storage
|
|
17
|
-
* support for backup rotation. we don’t want backups filling all the diskspace or cost a fortune on S3 or Cloud Files
|
|
18
|
-
|
|
19
|
-
And since we didn't find any, we wrote our own :)
|
|
20
|
-
|
|
21
|
-
## Contributions
|
|
22
|
-
|
|
23
|
-
The following functionality was contributed by webtranslateit-safe users:
|
|
24
|
-
|
|
25
|
-
* PostgreSQL dump using `pg_dump` (by Mark Mansour <mark@stateofflux.com>)
|
|
26
|
-
* Subversion dump using svndump (by Richard Luther <richard.luther@gmail.com>)
|
|
27
|
-
* SFTP remote storage (by Adam <adam@mediadrive.ca>)
|
|
28
|
-
* benchmarking output (By Neer)
|
|
29
|
-
* README fixes (by Bobby Wilson)
|
|
30
|
-
* improved config file parsing (by Fedor Kocherga <fkocherga@gmail.com>)
|
|
31
|
-
* mysql password file quoting (by Jonathan Sutherland <jonathan.sutherland@gmail.com>)
|
|
32
|
-
* Rackspace Cloud Files support (by H. Wade Minter <minter@lunenburg.org>)
|
|
33
|
-
* Plan FTP support (by seroy <seroy@bk.ru>)
|
|
34
|
-
* mongodump support (by Matt Berther <matt@mattberther.com>)
|
|
35
|
-
|
|
36
|
-
Thanks to all :)
|
|
9
|
+
- Support for ruby 3.2
|
|
10
|
+
- Standardized code with rubocop
|
|
11
|
+
- Added support for SCP transfers — On some conditions with servers with higher latency, transfering large files (> 18GB) with SFTP can take a very long time.
|
|
37
12
|
|
|
38
13
|
## Installation
|
|
39
14
|
|
|
@@ -83,7 +58,7 @@ We recommend also pringing the hard paper copy of your GPG key 'just in case'.
|
|
|
83
58
|
|
|
84
59
|
The procedure to create and transfer the key is as follows:
|
|
85
60
|
|
|
86
|
-
1. run
|
|
61
|
+
1. run `gpg --gen-key` on your local machine and follow onscreen instructions to create the key
|
|
87
62
|
(you can accept all the defaults).
|
|
88
63
|
|
|
89
64
|
2. extract your public key into a file (assuming you used test@example.com as your key email):
|
|
@@ -94,151 +69,148 @@ The procedure to create and transfer the key is as follows:
|
|
|
94
69
|
|
|
95
70
|
4. import public key on the remote system:
|
|
96
71
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
72
|
+
``` bash
|
|
73
|
+
$ gpg --import test@example.com.pub
|
|
74
|
+
gpg: key 45CA9403: public key "Test Backup <test@example.com>" imported
|
|
75
|
+
gpg: Total number processed: 1
|
|
76
|
+
gpg: imported: 1
|
|
77
|
+
```
|
|
101
78
|
|
|
102
79
|
5. since we don't keep the secret part of the key on the remote server, gpg has
|
|
103
80
|
no way to know its yours and can be trusted.
|
|
104
81
|
To fix that we can sign it with other trusted key, or just directly modify its
|
|
105
82
|
trust level in gpg (use level 5):
|
|
106
83
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
84
|
+
``` bash
|
|
85
|
+
$ gpg --edit-key test@example.com
|
|
86
|
+
...
|
|
87
|
+
Command> trust
|
|
88
|
+
...
|
|
89
|
+
1 = I don't know or won't say
|
|
90
|
+
2 = I do NOT trust
|
|
91
|
+
3 = I trust marginally
|
|
92
|
+
4 = I trust fully
|
|
93
|
+
5 = I trust ultimately
|
|
94
|
+
m = back to the main menu
|
|
95
|
+
|
|
96
|
+
Your decision? 5
|
|
97
|
+
...
|
|
98
|
+
Command> quit
|
|
99
|
+
```
|
|
121
100
|
|
|
122
101
|
6. export your secret key for backup
|
|
123
102
|
(we recommend to print it on paper and burn to a CD/DVD and store in a safe place):
|
|
124
103
|
|
|
125
|
-
|
|
126
|
-
|
|
104
|
+
``` bash
|
|
105
|
+
$ gpg -a --export-secret-key test@example.com > test@example.com.key
|
|
106
|
+
```
|
|
107
|
+
## Example configuration
|
|
127
108
|
|
|
109
|
+
``` ruby
|
|
110
|
+
safe do
|
|
111
|
+
verbose true
|
|
112
|
+
|
|
113
|
+
local path: "/backup/:kind/:id"
|
|
114
|
+
|
|
115
|
+
s3 do
|
|
116
|
+
key "...................."
|
|
117
|
+
secret "........................................"
|
|
118
|
+
bucket "backup.astrails.com"
|
|
119
|
+
path "servers/alpha/:kind/:id"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
cloudfiles do
|
|
123
|
+
user "..........."
|
|
124
|
+
api_key "................................."
|
|
125
|
+
container "safe_backup"
|
|
126
|
+
path ":kind/" # this is default
|
|
127
|
+
service_net false
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
sftp do
|
|
131
|
+
host "sftp.astrails.com"
|
|
132
|
+
user "astrails"
|
|
133
|
+
# port 8023
|
|
134
|
+
password "ssh password for sftp"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
sftp do
|
|
138
|
+
host "sftp.astrails.com"
|
|
139
|
+
user "astrails"
|
|
140
|
+
# port 8023
|
|
141
|
+
password "ssh password for scp"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
gpg do
|
|
145
|
+
command "/usr/local/bin/gpg"
|
|
146
|
+
options "--no-use-agent"
|
|
147
|
+
# symmetric encryption key
|
|
148
|
+
# password "qwe"
|
|
149
|
+
|
|
150
|
+
# public GPG key (must be known to GPG, i.e. be on the keyring)
|
|
151
|
+
key "backup@astrails.com"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
keep do
|
|
155
|
+
local 20
|
|
156
|
+
s3 100
|
|
157
|
+
cloudfiles 100
|
|
158
|
+
sftp 100
|
|
159
|
+
scp 100
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
mysqldump do
|
|
163
|
+
options "-ceKq --single-transaction --create-options"
|
|
164
|
+
|
|
165
|
+
user "root"
|
|
166
|
+
password "............"
|
|
167
|
+
socket "/var/run/mysqld/mysqld.sock"
|
|
168
|
+
|
|
169
|
+
database :blog
|
|
170
|
+
database :servershape
|
|
171
|
+
database :astrails_com
|
|
172
|
+
database :secret_project_com do
|
|
173
|
+
skip_tables "foo"
|
|
174
|
+
skip_tables ["bar", "baz"]
|
|
175
|
+
end
|
|
128
176
|
|
|
129
|
-
|
|
177
|
+
end
|
|
130
178
|
|
|
131
|
-
|
|
132
|
-
|
|
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
|
|
179
|
+
svndump do
|
|
180
|
+
repo :my_repo do
|
|
181
|
+
repo_path "/home/svn/my_repo"
|
|
233
182
|
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
pgdump do
|
|
186
|
+
options "-i -x -O" # -i => ignore version, -x => do not dump privileges (grant/revoke), -O => skip restoration of object ownership in plain text format
|
|
187
|
+
|
|
188
|
+
user "username"
|
|
189
|
+
password "............" # shouldn't be used, instead setup ident. Current functionality exports a password env to the shell which pg_dump uses - untested!
|
|
234
190
|
|
|
235
|
-
|
|
191
|
+
database :blog
|
|
192
|
+
database :stateofflux_com
|
|
193
|
+
end
|
|
236
194
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
195
|
+
tar do
|
|
196
|
+
options "-h" # dereference symlinks
|
|
197
|
+
archive "git-repositories", files: "/home/git/repositories"
|
|
198
|
+
archive "dot-configs", files: "/home/*/.[^.]*"
|
|
199
|
+
archive "etc", files: "/etc", exclude: "/etc/puppet/other"
|
|
200
|
+
|
|
201
|
+
archive "blog-astrails-com" do
|
|
202
|
+
files "/var/www/blog.astrails.com/"
|
|
203
|
+
exclude "/var/www/blog.astrails.com/log"
|
|
204
|
+
exclude "/var/www/blog.astrails.com/tmp"
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
archive "astrails-com" do
|
|
208
|
+
files "/var/www/astrails.com/"
|
|
209
|
+
exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
```
|
|
242
214
|
|
|
243
215
|
## Copyright
|
|
244
216
|
|
data/bin/webtranslateit-safe
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require '
|
|
4
|
-
|
|
5
|
-
require 'webtranslateit/safe'
|
|
3
|
+
require 'web_translate_it/safe'
|
|
6
4
|
|
|
7
5
|
include WebTranslateIt::Safe
|
|
8
6
|
|
|
@@ -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]
|
|
@@ -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 = {}, &
|
|
11
|
+
def initialize(parent = nil, data = {}, &)
|
|
13
12
|
@parent = parent
|
|
14
13
|
@data = {}
|
|
15
|
-
merge
|
|
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(&
|
|
51
|
-
@data.each(&
|
|
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
|
-
|
|
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
|
|
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?
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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, &
|
|
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(&
|
|
33
|
+
to_remove.each(&)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
end
|
|
@@ -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.
|
|
4
|
+
version: 0.4.7
|
|
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/
|
|
85
|
-
- lib/
|
|
86
|
-
- lib/
|
|
87
|
-
- lib/
|
|
88
|
-
- lib/
|
|
89
|
-
- lib/
|
|
90
|
-
- lib/
|
|
91
|
-
- lib/
|
|
92
|
-
- lib/
|
|
93
|
-
- lib/
|
|
94
|
-
- lib/
|
|
95
|
-
- lib/
|
|
96
|
-
- lib/
|
|
97
|
-
- lib/
|
|
98
|
-
- lib/
|
|
99
|
-
- lib/
|
|
100
|
-
- lib/
|
|
101
|
-
- lib/
|
|
102
|
-
- lib/
|
|
103
|
-
- lib/
|
|
104
|
-
- lib/
|
|
105
|
-
- lib/
|
|
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
|
data/lib/webtranslateit/safe.rb
DELETED
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|