Informatika Mihelac
January 15 2007 capistrano | rails

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

Speak your mind:

(Required)

(Required)


(You may use textile in your comments.)

About

I am Bojan Mihelac and this blog is dedicated to share code, thoughts, tools and advices I came up with while working in Informatika Mihelac.

Contact: bmihelac@mihelac.org

RSS feedSubscribe to RSS Feed