Return to Snippet

Revision: 19898
at November 3, 2009 11:02 by nate63179


Initial Code
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'erb'
require 'yaml'

unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[RAILS_ENV]
  abort "No database is configured for the environment '#{RAILS_ENV}'"
end

db_out_path = File.join(RAILS_ROOT, 'tmp', "dbdump_#{RAILS_ENV}.sql")
system "mysqldump -u #{config['username']} --password=#{config['password']} #{config['database']} > #{db_out_path}"

Initial URL

                                

Initial Description

                                

Initial Title
Rails: Backup a mysql database script

Initial Tags
mysql, database, rails

Initial Language
Rails