blob: f031ea2d2f5695d20b0799b05e227acb2004ee7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
set(:postgresql_host, "localhost")
namespace :db 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
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)
#execute "s3cmd sync #{shared_path}/backups/*.dump s3://#{ENV['AWS_S3_BACKUPS_BUCKET']}/#{fetch(:rails_env)}/pg/"
end
end
end
|