mysql_truck 0.0.8 → 0.1.1

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.
data/TODO CHANGED
@@ -1,4 +1,8 @@
1
1
  # TODO
2
2
 
3
+ * Download/extract/import one table at a time.
4
+ * Rework backup so that table schema and indexes are separated.
5
+ * Rework restore so that schema is applied, data is imported, then indexes are
6
+ applied.
3
7
  * Add ability to manage number of backups on S3
4
8
  * Better error handling messages rather than stack dumps
data/lib/mysql_truck.rb CHANGED
@@ -165,8 +165,14 @@ module MysqlTruck
165
165
  initialize_s3
166
166
  end
167
167
 
168
- def skip_tables
169
- config[:skip_tables] || []
168
+ # only import schema for these tables
169
+ def skip_data_for_tables
170
+ config[:skip_data_for_tables] || []
171
+ end
172
+
173
+ # only import these tables schema+data
174
+ def only_tables
175
+ config[:only_tables] || []
170
176
  end
171
177
 
172
178
  def load_latest
@@ -214,13 +220,15 @@ module MysqlTruck
214
220
  end
215
221
 
216
222
  def download_file(key)
217
- filename = File.basename(key.name)
218
- print " - Downloading #{filename} ... "
219
-
220
- if filename.match(/\.csv\.gz$/) && skip_tables.include?(File.basename(filename, ".csv.gz"))
221
- puts " [ Skipping ]"
222
- return false
223
+ filename = File.basename(key.name)
224
+ print "#{filename}... "
225
+
226
+ unless should_download_file?(filename)
227
+ puts " [ SKIP ]"
228
+ return
223
229
  end
230
+
231
+ print " Downloading... "
224
232
 
225
233
  File.open(tmp_path.join(filename), "wb") do |f|
226
234
  @bucket.s3.interface.get(@bucket.name, key.name) do |chunk|
@@ -228,10 +236,36 @@ module MysqlTruck
228
236
  end
229
237
  end
230
238
 
231
- print "complete.\n"
239
+ puts "complete."
232
240
  filename
233
241
  end
234
242
 
243
+ def should_download_file?(filename)
244
+ table_name = filename.gsub(/\..*\..*$/, '')
245
+
246
+ if only_tables.empty? and skip_data_for_tables.empty?
247
+ return true
248
+ end
249
+
250
+ if filename.match(/\.csv\.gz$/)
251
+ is_data = true
252
+ is_schema = false
253
+ else
254
+ is_data = false
255
+ is_schema = true
256
+ end
257
+
258
+ if !only_tables.empty?
259
+ return only_tables.include?(table_name)
260
+ end
261
+
262
+ if !skip_data_for_tables.empty?
263
+ if is_schema or (is_data and !skip_data_for_tables.include?(table_name))
264
+ return true
265
+ end
266
+ end
267
+ end
268
+
235
269
  # Get a list of backups stored on S3.
236
270
  #
237
271
  # Returns an array of s3 paths that look like:
@@ -1,3 +1,3 @@
1
1
  module MysqlTruck
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.1"
3
3
  end
data/mysql_truck.gemspec CHANGED
@@ -5,8 +5,8 @@ require "mysql_truck/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "mysql_truck"
7
7
  s.version = MysqlTruck::VERSION
8
- s.authors = ["Peter Bui", "8tracks"]
9
- s.email = ["peter@paydrotalks.com"]
8
+ s.authors = ["Peter Bui", "Remi Gabillet", "8tracks"]
9
+ s.email = ["peter@paydrotalks.com", "rgabillet@gmail.com"]
10
10
  s.homepage = ""
11
11
  s.summary = %q{Mysql database backup tool. Dumps/Loads to/from S3.}
12
12
  s.description = %q{Mysql database backup tool. Dumps/Loads to/from S3.}
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_truck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter Bui
9
+ - Remi Gabillet
9
10
  - 8tracks
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2011-09-20 00:00:00.000000000 -07:00
14
- default_executable:
14
+ date: 2011-12-29 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: right_aws
18
- requirement: &2156462860 !ruby/object:Gem::Requirement
18
+ requirement: &70123421522780 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,11 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2156462860
26
+ version_requirements: *70123421522780
27
27
  description: Mysql database backup tool. Dumps/Loads to/from S3.
28
28
  email:
29
29
  - peter@paydrotalks.com
30
+ - rgabillet@gmail.com
30
31
  executables:
31
32
  - mysql_truck
32
33
  extensions: []
@@ -40,7 +41,6 @@ files:
40
41
  - lib/mysql_truck.rb
41
42
  - lib/mysql_truck/version.rb
42
43
  - mysql_truck.gemspec
43
- has_rdoc: true
44
44
  homepage: ''
45
45
  licenses: []
46
46
  post_install_message:
@@ -61,8 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 1.6.2
64
+ rubygems_version: 1.8.10
65
65
  signing_key:
66
66
  specification_version: 3
67
67
  summary: Mysql database backup tool. Dumps/Loads to/from S3.
68
68
  test_files: []
69
+ has_rdoc: