mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 14:11:10 +00:00
Add a rake task to the deployment to backup the DB.
Apparently needed with all the broken migrations...
This commit is contained in:
parent
f2bbb68ad9
commit
f212aeeb30
2 changed files with 18 additions and 1 deletions
11
lib/tasks/dump_db.rake
Normal file
11
lib/tasks/dump_db.rake
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require 'yaml'
|
||||
task :dump_db do
|
||||
yaml = YAML.load_file("config/database.yml")
|
||||
conf = yaml["production"]
|
||||
filename = "#{conf["database"]}-#{Time.now.strftime("%Y-%m-%d-%H:%M:%S:%L")}.sql"
|
||||
if conf["adapter"] == 'mysql2'
|
||||
system "mysqldump -u #{conf["username"]} --password=#{conf["password"]} -h #{conf["host"]} #{conf["database"]} > ~/#{filename}"
|
||||
else
|
||||
puts "Error: This rake task only works for MYSQL"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue