summaryrefslogtreecommitdiff
path: root/lib/capistrano/tasks/postgresql.rake
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-08-22 23:03:53 -0600
committermo khan <mo@mokhan.ca>2014-08-22 23:03:53 -0600
commit2eddc06110f09cfa302fbf4d46868900688c84b2 (patch)
tree9c41157e682f42fef7196afc2b9baddbdef3ee3e /lib/capistrano/tasks/postgresql.rake
parent52875ff8bf373754723f28fad263b10300ec0077 (diff)
get db backup cap task working.
Diffstat (limited to 'lib/capistrano/tasks/postgresql.rake')
-rw-r--r--lib/capistrano/tasks/postgresql.rake16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/capistrano/tasks/postgresql.rake b/lib/capistrano/tasks/postgresql.rake
index f80d4487..09257e28 100644
--- a/lib/capistrano/tasks/postgresql.rake
+++ b/lib/capistrano/tasks/postgresql.rake
@@ -1,19 +1,15 @@
set(:postgresql_host, "localhost")
-#set(:postgresql_user) { fetch(:application) }
-#set(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
-#set(:postgresql_database) { "#{fetch(:application)}_#{fetch(:rails_env)}" }
namespace :postgresql do
desc "Backup the database and copy it locally"
task :backup do
+ filename = "#{fetch(:rails_env)}-#{Time.now.strftime('%Y-%m-%d-%H-%M')}.dump"
+ backup_path = "#{shared_path}/backups"
+ ask(:postgresql_password, "default")
on roles(:db) do
- filename = "#{fetch(:rails_env)}-#{Time.now.strftime('%Y-%m-%d-%H-%M')}.dump"
- backup_path = "#{fetch(:shared_path)}/backups"
- run "mkdir -p #{fetch(:shared_path)}/backups"
-
- ask(:postgresql_password, "default", echo: false)
- run "PGPASSWORD='#{postgresql_password}' pg_dump -Fc --no-acl --no-owner -h #{fetch(:postgresql_host)} -U deployer cakeside > #{backup_path}/#{filename}"
- download("#{backup_path}/#{filename}", "db/backups/", :via => :scp)
+ execute "mkdir -p #{shared_path}/backups"
+ execute "PGPASSWORD='#{fetch(:postgresql_password)}' pg_dump -Fc --no-acl --no-owner -h #{fetch(:postgresql_host)} -U deployer cakeside > #{backup_path}/#{filename}"
+ download!("#{backup_path}/#{filename}", "db/backups/", :via => :scp)
end
end
end