ll-innobackup 0.1.20 → 0.1.25

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 (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/ll-innobackup.rb +18 -8
  3. metadata +34 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e822135070e395eb93e490d1fb13c69e7ca4bcb7
4
- data.tar.gz: 0abda3c7121759c254444334397d7b893c79ad89
2
+ SHA256:
3
+ metadata.gz: fd4efe2cc26ec55323d76eabcc4b30152dc75d3a4cb1970b778acb91f9241777
4
+ data.tar.gz: 735208065ac94159dd58a0fe42880cb9f5fa45ac104629dd163fa3ff63daed3d
5
5
  SHA512:
6
- metadata.gz: 1b970a97f2090c57a67015c32f386084dd58ef6bfd9c7f020a303156490da3e5e12827c2d79fdbb3bb349b0e2843aba82cd5967cfd574fbf299a7a4b77202a4e
7
- data.tar.gz: 85e7231eb9aafed5b399b75cab6219eb11bbe1761c88aa9a3f9fb7c3a995302dea2108f7a09b824d873dd8bdf58733144225f384f3605ac938af741cec38b251
6
+ metadata.gz: 8feeba652828c7b8e68332a65636f1ea90031c1badfa6d405dd4f5165a7adef8dec73ec8ff2204917c1c01a16f9944fd713d53e007574709dc62417a2707e30b
7
+ data.tar.gz: ae3be48a9ad23170afb6d64ea89f8ef1306debe967058a6144c881d3b681e0c673534ab32a8afeb7509b0fb3c49eec407af4f70727f9ca4f31249aa1f2823239
data/lib/ll-innobackup.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
2
  require 'date'
3
+ require 'aws-sdk-s3'
3
4
 
4
5
  # Run Inmental or Full backups on MySQL
5
6
  module LL
@@ -62,7 +63,8 @@ class InnoBackup
62
63
  :date,
63
64
  :state_files,
64
65
  :lock_files,
65
- :options
66
+ :options,
67
+ :s3
66
68
 
67
69
  def initialize(options = {})
68
70
  @now = Time.now
@@ -71,6 +73,7 @@ class InnoBackup
71
73
  @lock_files = {}
72
74
  @state_files = {}
73
75
  @type = backup_type
76
+ @s3 = Aws::S3::Resource.new()
74
77
  end
75
78
 
76
79
  def aws_log
@@ -139,6 +142,10 @@ class InnoBackup
139
142
  @backup_compress_threads = options['backup_compress_threads'] ||= 4
140
143
  end
141
144
 
145
+ def encryption_threads
146
+ @encryption_threads = options['encryption_threads'] ||= 4
147
+ end
148
+
142
149
  def sql_backup_user
143
150
  @sql_backup_user ||= options['sql_backup_user']
144
151
  end
@@ -181,7 +188,7 @@ class InnoBackup
181
188
  [
182
189
  "--parallel=#{backup_parallel}",
183
190
  "--compress-threads=#{backup_compress_threads}",
184
- ("--encrypt=AES256 --encrypt-key=#{encryption_key}" if is_encrypted?),
191
+ ("--encrypt=AES256 --encrypt-key=#{encryption_key} --encrypt-threads=#{encryption_threads}" if is_encrypted?),
185
192
  '--stream=xbstream --compress'
186
193
  ].join(" ")
187
194
  end
@@ -213,10 +220,14 @@ class InnoBackup
213
220
  "--expected-size=#{expected_full_size}" if type == 'full'
214
221
  end
215
222
 
216
- def aws_command
217
- "#{aws_bin} s3 cp #{working_file} s3://#{aws_bucket}/#{aws_backup_file} "\
218
- "#{expected_size} #{expires} "\
219
- "2> #{aws_log} >> #{aws_log}"
223
+ def s3object_uploaded?(bucket_name, object_key, file_path)
224
+ object = @s3.bucket(bucket_name).object(object_key)
225
+ object.upload_file(file_path, {expires: expires_date, thread_count: @options['thread_count']}) do |r|
226
+ return true
227
+ end
228
+ rescue StandardError => e
229
+ STDERR.puts "Error uploading object: #{e.message}"
230
+ return false
220
231
  end
221
232
 
222
233
  def valid_commands?
@@ -230,8 +241,7 @@ class InnoBackup
230
241
  `#{innobackup_command}`
231
242
  @completed_inno = $CHILD_STATUS == 0
232
243
  raise InnoBackup::StateError, 'Unable to run innobackup correctly' unless @completed_inno
233
- `#{aws_command}`
234
- @completed_aws = $CHILD_STATUS == 0
244
+ @completed_aws = s3object_uploaded?(aws_bucket, aws_backup_file, working_file)
235
245
  raise InnoBackup::StateError, 'Unable to run aws upload correctly' unless @completed_aws
236
246
  return record if success? && completed?
237
247
  rescue InnoBackup::StateError => e
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ll-innobackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Harland, LiveLink Technology Ltd
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-06 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-s3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 5.12.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 5.12.0
27
55
  description: A program to conduct innobackup
28
56
  email: essjayhch@gmail.com, infra@livelinktechnology.net
29
57
  executables:
@@ -37,7 +65,7 @@ homepage: http://rubygems.org/gems/ll-innobackup
37
65
  licenses:
38
66
  - MIT
39
67
  metadata: {}
40
- post_install_message:
68
+ post_install_message:
41
69
  rdoc_options: []
42
70
  require_paths:
43
71
  - lib
@@ -52,9 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
80
  - !ruby/object:Gem::Version
53
81
  version: '0'
54
82
  requirements: []
55
- rubyforge_project:
56
- rubygems_version: 2.5.2.3
57
- signing_key:
83
+ rubygems_version: 3.1.4
84
+ signing_key:
58
85
  specification_version: 4
59
86
  summary: Livelink Innobackup Script
60
87
  test_files: []