diff options
| author | mo k <mo@mokhan.ca> | 2012-09-22 21:28:52 -0600 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-09-22 21:28:52 -0600 |
| commit | 2e1cb4ea3ba17717a8e2b8598a66b5a81c5ed13b (patch) | |
| tree | d04609cf8d75c9202eeff086f845909c0ff8ae39 /lib | |
| parent | 68645158b14c72f9f79a4642d06381a651de53e9 (diff) | |
rake db:restore will restore the prod db to the local database.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tasks/database.rake | 22 | ||||
| -rw-r--r-- | lib/tasks/deployment.rake | 1 |
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/tasks/database.rake b/lib/tasks/database.rake index 5e6a161c..b92536c0 100644 --- a/lib/tasks/database.rake +++ b/lib/tasks/database.rake @@ -1,8 +1,16 @@ -task :restore do - # 1. backup prod database - sh "cap production backup_db" - # 2. copy backup to staging - sh "rm -f latest && ln -s db/backups/`ls -rt db/backups/ | tail -n1` latest" - # 3. restore backup on staging - sh "cap staging restore_db" +namespace :db do + task :restore do + dumpfile = "latest" + config = Rails.configuration.database_configuration + destination_db = config[Rails.env]["database"] + puts "restoring to #{destination_db}" + sh "psql #{destination_db} < #{dumpfile}" + end + task :backup do + sh "cap production backup_db" + sh "rm -f latest && ln -s db/backups/`ls -rt db/backups/ | tail -n1` latest" + end + task :restore_to_staging => :backup do + sh "cap staging restore_db" + end end diff --git a/lib/tasks/deployment.rake b/lib/tasks/deployment.rake index 3edd22eb..31d7d19b 100644 --- a/lib/tasks/deployment.rake +++ b/lib/tasks/deployment.rake @@ -1,7 +1,6 @@ namespace :deploy do desc "deploy to staging server" task :staging => :spec do - #sh "cap staging deploy" sh "cap staging deploy:migrations" sh "curl http://staging.cakeside.com/ > /dev/null" end |
