Skip to content

Instantly share code, notes, and snippets.

@ignat-z
Created October 13, 2013 02:04
Show Gist options
  • Save ignat-z/6957248 to your computer and use it in GitHub Desktop.
Save ignat-z/6957248 to your computer and use it in GitHub Desktop.
OpenShift rake task to create dumpfile
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