summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-08-09 13:56:47 -0600
committermo khan <mo@mokhan.ca>2013-08-09 13:56:47 -0600
commit84ee59c6137ebe0e870aa47351bc06708b1260a8 (patch)
tree7803fa06bd5fbe95a789c24472725b84937146a6 /config
parent48f1b63b003425116a1ab8ff70cd5603e78c1c36 (diff)
extract backup_path and add hours and minute to backup file timestamp
Diffstat (limited to 'config')
-rw-r--r--config/recipes/postgresql.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/config/recipes/postgresql.rb b/config/recipes/postgresql.rb
index 6e80ebb..ee19b02 100644
--- a/config/recipes/postgresql.rb
+++ b/config/recipes/postgresql.rb
@@ -35,11 +35,12 @@ namespace :postgresql do
desc "Backup the database and copy it locally"
task :backup, roles: :db, only: {primary: true} do
- filename = "#{rails_env}-#{Time.now.strftime('%Y-%m-%d')}.sql"
+ filename = "#{rails_env}-#{Time.now.strftime('%Y-%m-%d-%H-%M')}.sql"
+ backup_path = "#{shared_path}/backups"
run "mkdir -p #{shared_path}/backups"
- run "pg_dump --clean -h #{postgresql_host} -U #{postgresql_user} -W #{postgresql_database} > #{shared_path}/backups/#{filename}" do |channel, stream, data|
+ run "pg_dump --clean -h #{postgresql_host} -U #{postgresql_user} -W #{postgresql_database} > #{backup_path}/#{filename}" do |channel, stream, data|
channel.send_data "#{postgresql_password}\n"
end
- download("#{shared_path}/backups/#{filename}", "tmp/#{filename}", :via => :scp)
+ download("#{backup_path}/#{filename}", "tmp/#{filename}", :via => :scp)
end
end