Jan 15
Backup remote database with Capistrano
Based on and using capistrano get method posted few days before here comes capistrano recipe to backup database on remote server.
desc <<DESC
Backup remote database from primary server.
DESC
task :remote_backup, :roles => :db, :only => { :primary => true } do
filename = "dump.#{Time.now.strftime '%Y%m%dT%:%H%M%S'}.sql"
on_rollback { delete "/tmp/#{filename}" }
run "mysqldump -uusername -ppassword database_name > \n
/tmp/#{filename}" do |channel, stream, data|
puts data
end
get "/tmp/#{filename}", "c:/backup/#{filename}"
delete "/tmp/#{filename}"
end
I am Bojan Mihelac and this blog is dedicated to share code, thoughts, tools and advices I came up with while working at
blog comments powered by Disqus