mysql_truck 0.4.0 → 0.5.0

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/bin/mysql_truck CHANGED
@@ -52,6 +52,10 @@ parser = OptionParser.new do |opts|
52
52
  options[:backup_date] = backup_date
53
53
  end
54
54
 
55
+ opts.on("-D", "--date-suffix", "Append date at the end of table names") do
56
+ options[:date_suffix] = true
57
+ end
58
+
55
59
  opts.on("--bucket-dir BUCKET_DIR", "S3 bucket dir [defaults to database name]") do |dir|
56
60
  options[:bucket_dir] = dir
57
61
  end
@@ -20,9 +20,7 @@ module MysqlTruck
20
20
 
21
21
  def load_backup
22
22
  # Default to latest backup
23
- unless config[:backup_date]
24
- backup_date_str = backups.first.split("/").last
25
- end
23
+ backup_date_str = config[:backup_date] || backups.first.split("/").last
26
24
 
27
25
  # Set directory where backup is downloaded to
28
26
  @time = Time.new(backup_date_str.split("-"))
@@ -75,8 +73,15 @@ module MysqlTruck
75
73
 
76
74
  if data_file.exist?
77
75
  print " - Importing #{schema_file.basename(".sql")} ... "
76
+
77
+ commands = ["cat #{data_file}"]
78
+ if config[:date_suffix]
79
+ commands << "sed 's/INTO #{table}/INTO #{table}_#{backup_date_str.gsub(/-/, "")}/g'"
80
+ end
81
+ commands << "mysql #{db_connection_options}"
82
+
78
83
  time = benchmark do
79
- `cat #{data_file} | mysql #{db_connection_options}`
84
+ `#{commands.join(" | ")`
80
85
  end
81
86
  print "complete (#{formatted_time time}).\n"
82
87
  end
@@ -1,3 +1,3 @@
1
1
  module MysqlTruck
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_truck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2012-09-18 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: right_aws
18
- requirement: &70248160930520 !ruby/object:Gem::Requirement
18
+ requirement: &70203072509000 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,7 +23,7 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70248160930520
26
+ version_requirements: *70203072509000
27
27
  description: Mysql database backup tool. Dumps/Loads to/from S3.
28
28
  email:
29
29
  - peter@paydrotalks.com