Class: Savior::Database
- Inherits:
-
Object
- Object
- Savior::Database
- Defined in:
- lib/savior/database.rb
Instance Method Summary collapse
- #create_snapshot ⇒ Object
-
#initialize(options = {}) ⇒ Database
constructor
A new instance of Database.
Constructor Details
#initialize(options = {}) ⇒ Database
Returns a new instance of Database.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/savior/database.rb', line 3 def initialize( = {}) = { :user => nil, :password => nil, :host => "localhost", :port => "3306", :database_name => nil, } = .merge() @user = [:user] @password = [:password] @host = [:host] @port = [:port] @database_name = [:database_name] end |
Instance Method Details
#create_snapshot ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/savior/database.rb', line 19 def create_snapshot db_snapshot_file = set_db_snapshot_file_name file = File.open(db_snapshot_file, "w+") IO.popen("mysqldump #{}","r+") do |pipe| pipe.close_write while (line = pipe.gets) file.puts line end end file.close db_snapshot_file end |