Class: DB2Fog::MysqlAdaptor
- Inherits:
-
Object
- Object
- DB2Fog::MysqlAdaptor
- Defined in:
- lib/db2fog.rb
Instance Method Summary collapse
- #dump(*args) ⇒ Object
-
#initialize(credentials) ⇒ MysqlAdaptor
constructor
A new instance of MysqlAdaptor.
- #restore(path) ⇒ Object
Constructor Details
#initialize(credentials) ⇒ MysqlAdaptor
Returns a new instance of MysqlAdaptor.
85 86 87 |
# File 'lib/db2fog.rb', line 85 def initialize(credentials) @credentials = credentials end |
Instance Method Details
#dump(*args) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/db2fog.rb', line 89 def dump *args = args. dump_file = Tempfile.new("dump") flags = "--quick --single-transaction --create-options" cmd = "mysqldump #{flags} #{} #{[:database]} " + [:tables].join(" ") cmd += " | gzip -9 > #{dump_file.path}" puts cmd run(cmd) Kernel.p dump_file.path dump_file.path end |
#restore(path) ⇒ Object
102 103 104 |
# File 'lib/db2fog.rb', line 102 def restore(path) run "gunzip -c #{path} | mysql #{}" end |