-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.rake
More file actions
26 lines (19 loc) · 719 Bytes
/
db.rake
File metadata and controls
26 lines (19 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
namespace :db do
desc 'Dumps the entire database to an sql file.'
task :dump => :environment do
db_config = Rails.configuration.database_configuration
user = db_config[Rails.env]['username']
password = db_config[Rails.env]['password']
host = db_config[Rails.env]['host']
database = db_config[Rails.env]['database']
filename = "dump-#{Rails.env}-#{Time.now.strftime('%Y-%m-%d')}.sql"
command = 'mysqldump'
command += ' --add-drop-table'
command += " -u #{user}"
command += " -h #{host}" unless host.blank?
command += " -p#{password}" unless password.blank?
command += " #{database}"
command += " > #{filename}"
sh command
end
end