Created
October 13, 2013 02:04
-
-
Save ignat-z/6957248 to your computer and use it in GitHub Desktop.
OpenShift rake task to create dumpfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc "Make OpenShift database dump" | |
task :dump do | |
enviroment = Rails.env || ENV['RAILS_ENV'] || 'production' | |
config = Rails.configuration.database_configuration[enviroment] | |
password = config['password'] | |
username = config['username'] || 'root' | |
host = config['host'] | |
port = config['port'] || 3306 | |
filemame = ['backup', Time.now.strftime("%Y%m%d")].join('_') | |
`mysqldump -h#{host} -P#{port} -u#{username} -p#{password} --all-databases > ~/app-root/data/tmp/#{filemame}.sql` | |
puts "Finished. Filename: #{filemame}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment