ll-innobackup 0.1.14 → 0.1.17
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/lib/ll-innobackup.rb +52 -34
- metadata +8 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 674c9b52e1430fc97e86f45a30b0a3fe97a94213
|
4
|
+
data.tar.gz: c5835dba0684dbeae24a28053bf0f02e0c30632e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f37aa88c6405f105dc2f11e6ee7cb5c8cd0d78b9029a8bf1c2ed2f8aa2ac1c3f60fa115255fab02d8d20f7e929ab714ab6f6f5635e64fe424dab430266652d6
|
7
|
+
data.tar.gz: 6d54cea60e3eda26a747826052380fba7de8352b5ec04e413ddbc970c3881ea80ac9b3ff40b18fd3f14f388387f6bdfab0b25fe5ca8cd7f1ea077eb19aba52e1
|
data/lib/ll-innobackup.rb
CHANGED
@@ -84,25 +84,24 @@ class InnoBackup
|
|
84
84
|
def lock?(t = type)
|
85
85
|
lock_files[t] ||= File.new(InnoBackup.lock_file(t), File::CREAT)
|
86
86
|
lock_files[t].flock(File::LOCK_NB | File::LOCK_EX).zero?
|
87
|
-
rescue NoMethodError
|
88
|
-
false
|
89
87
|
end
|
90
88
|
|
91
89
|
def state(t)
|
92
90
|
state_files[t] ||= JSON.parse(File.read(InnoBackup.state_file(t)))
|
93
|
-
rescue Errno::ENOENT
|
94
|
-
{}
|
95
91
|
rescue JSON::ParserError
|
92
|
+
puts 'unable to stat state file'
|
96
93
|
{}
|
97
94
|
end
|
98
95
|
|
99
96
|
def fully_backed_up_today?
|
100
97
|
require 'active_support/all'
|
101
98
|
date = state('full')['date']
|
102
|
-
Time.parse(date).today?
|
99
|
+
Time.parse(date).today?
|
103
100
|
rescue Errno::ENOENT
|
101
|
+
puts 'unable to obtain last full backup state'
|
104
102
|
false
|
105
103
|
rescue NoMethodError
|
104
|
+
puts 'unable to obtain last backup state'
|
106
105
|
false
|
107
106
|
end
|
108
107
|
|
@@ -153,12 +152,17 @@ class InnoBackup
|
|
153
152
|
@aws_bucket = options['aws_bucket']
|
154
153
|
end
|
155
154
|
|
156
|
-
def
|
157
|
-
|
155
|
+
def working_directory
|
156
|
+
return options['working_directory'] if options['working_directory']
|
157
|
+
'/tmp'
|
158
158
|
end
|
159
159
|
|
160
|
-
def
|
161
|
-
@
|
160
|
+
def expected_full_size
|
161
|
+
@expected_full_size ||= -> do
|
162
|
+
return File.size(working_file) if File.exist?(working_file)
|
163
|
+
return options['expected_full_size'] if options['expected_full_size']
|
164
|
+
1_600_000_000
|
165
|
+
end.call
|
162
166
|
end
|
163
167
|
|
164
168
|
def sql_authentication
|
@@ -173,7 +177,8 @@ class InnoBackup
|
|
173
177
|
|
174
178
|
def innobackup_command
|
175
179
|
"#{backup_bin} #{sql_authentication} "\
|
176
|
-
"#{incremental} #{innobackup_options} /tmp/sql"
|
180
|
+
"#{incremental} #{innobackup_options} /tmp/sql "\
|
181
|
+
"2> #{innobackup_log} > #{working_file}"
|
177
182
|
end
|
178
183
|
|
179
184
|
def expires_date
|
@@ -194,22 +199,13 @@ class InnoBackup
|
|
194
199
|
end
|
195
200
|
|
196
201
|
def expected_size
|
197
|
-
|
198
|
-
|
199
|
-
"--expected-size=#{es}" if es.to_i > 0
|
202
|
+
"--expected-size=#{expected_full_size}" if type == 'full'
|
200
203
|
end
|
201
204
|
|
202
205
|
def aws_command
|
203
|
-
"#{aws_bin} s3 cp
|
204
|
-
"
|
205
|
-
|
206
|
-
|
207
|
-
def aws_debug
|
208
|
-
"--debug" if debug_aws?
|
209
|
-
end
|
210
|
-
|
211
|
-
def debug_aws?
|
212
|
-
@debug_aws = (options['debug_aws'] == true)
|
206
|
+
"#{aws_bin} s3 cp #{working_file} s3://#{aws_bucket}/#{aws_backup_file} "\
|
207
|
+
"#{expected_size} #{expires} "\
|
208
|
+
"2> #{aws_log} >> #{aws_log}"
|
213
209
|
end
|
214
210
|
|
215
211
|
def valid_commands?
|
@@ -218,18 +214,22 @@ class InnoBackup
|
|
218
214
|
|
219
215
|
def backup
|
220
216
|
require 'English'
|
221
|
-
|
222
|
-
|
223
|
-
`#{
|
224
|
-
|
225
|
-
|
226
|
-
|
217
|
+
|
218
|
+
return unless valid_commands?
|
219
|
+
`#{innobackup_command}`
|
220
|
+
@completed_inno = $CHILD_STATUS == 0
|
221
|
+
raise Innobackup::StateError, 'Unable to run innobackup correctly' unless @completed_inno
|
222
|
+
`#{aws_command}`
|
223
|
+
@completed_aws = $CHILD_STATUS == 0
|
224
|
+
raise Innobackup::StateError, 'Unable to run aws upload correctly' unless @completed_aws
|
227
225
|
return record if success? && completed?
|
228
|
-
|
226
|
+
rescue Innobackup::StateError => e
|
227
|
+
revert_aws
|
229
228
|
rescue InnoBackup::NoStateError => e
|
230
229
|
STDERR.puts e.message
|
231
230
|
ensure
|
232
231
|
report
|
232
|
+
cleanup
|
233
233
|
end
|
234
234
|
|
235
235
|
def revert_aws
|
@@ -260,8 +260,6 @@ class InnoBackup
|
|
260
260
|
def incremental
|
261
261
|
return unless backup_type == 'incremental'
|
262
262
|
"--incremental --incremental-lsn=#{lsn_from_state}"
|
263
|
-
rescue Errno::ENOENT
|
264
|
-
''
|
265
263
|
end
|
266
264
|
|
267
265
|
def lsn_from_full_backup_state?
|
@@ -291,6 +289,10 @@ class InnoBackup
|
|
291
289
|
Socket.gethostbyname(Socket.gethostname).first
|
292
290
|
end
|
293
291
|
|
292
|
+
def working_file
|
293
|
+
@working_file ||= File.join working_directory, "#{now.iso8601}-percona_backup"
|
294
|
+
end
|
295
|
+
|
294
296
|
def aws_backup_file
|
295
297
|
return "#{hostname}/#{now.iso8601}/percona_full_backup" if type == 'full'
|
296
298
|
"#{hostname}/#{Time.parse(state('full')['date']).iso8601}/percona_incremental_#{now.iso8601}"
|
@@ -299,7 +301,21 @@ class InnoBackup
|
|
299
301
|
end
|
300
302
|
|
301
303
|
def completed?
|
302
|
-
|
304
|
+
completed_aws? && completed_inno?
|
305
|
+
end
|
306
|
+
|
307
|
+
def completed_aws?
|
308
|
+
@completed_aws == true
|
309
|
+
end
|
310
|
+
|
311
|
+
def completed_inno?
|
312
|
+
@completed_inno == true
|
313
|
+
end
|
314
|
+
|
315
|
+
def cleanup
|
316
|
+
File.unlink working_file
|
317
|
+
rescue StandardError => e
|
318
|
+
STDERR.puts "Caught exception #{e} when trying to cleanup"
|
303
319
|
end
|
304
320
|
|
305
321
|
def report
|
@@ -308,7 +324,9 @@ class InnoBackup
|
|
308
324
|
STDERR.puts "#{$PROGRAM_NAME}: success: completed #{type} backup"
|
309
325
|
return
|
310
326
|
end
|
311
|
-
STDERR.puts "
|
327
|
+
STDERR.puts "Unable to run innobackup" unless completed_inno?
|
328
|
+
STDERR.puts "Unable to run aws s3 command" unless completed_aws?
|
329
|
+
STDERR.puts "#{$PROGRAM_NAME}: failed"
|
312
330
|
STDERR.puts 'missing binaries' unless valid_commands?
|
313
331
|
inno_tail = InnoBackup.tail_file(innobackup_log, 10)
|
314
332
|
STDERR.puts 'invalid sql user' if inno_tail =~ /Option user requires an argument/
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ll-innobackup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.17
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Stuart Harland, LiveLink Technology Ltd
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2018-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,27 +20,10 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 4.2.6
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: json
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 1.8.6
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.8.6
|
46
27
|
description: A program to conduct innobackup
|
47
28
|
email: essjayhch@gmail.com, infra@livelinktechnology.net
|
48
29
|
executables:
|
@@ -50,31 +31,30 @@ executables:
|
|
50
31
|
extensions: []
|
51
32
|
extra_rdoc_files: []
|
52
33
|
files:
|
53
|
-
- lib/ll-innobackup.rb
|
54
34
|
- bin/ll-innobackup
|
35
|
+
- lib/ll-innobackup.rb
|
55
36
|
homepage: http://rubygems.org/gems/ll-innobackup
|
56
37
|
licenses:
|
57
38
|
- MIT
|
39
|
+
metadata: {}
|
58
40
|
post_install_message:
|
59
41
|
rdoc_options: []
|
60
42
|
require_paths:
|
61
43
|
- lib
|
62
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
45
|
requirements:
|
65
|
-
- -
|
46
|
+
- - ">="
|
66
47
|
- !ruby/object:Gem::Version
|
67
48
|
version: '0'
|
68
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
50
|
requirements:
|
71
|
-
- -
|
51
|
+
- - ">="
|
72
52
|
- !ruby/object:Gem::Version
|
73
53
|
version: '0'
|
74
54
|
requirements: []
|
75
55
|
rubyforge_project:
|
76
|
-
rubygems_version:
|
56
|
+
rubygems_version: 2.6.13
|
77
57
|
signing_key:
|
78
|
-
specification_version:
|
58
|
+
specification_version: 4
|
79
59
|
summary: Livelink Innobackup Script
|
80
60
|
test_files: []
|