Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
task :backup, :roles => :db, :only => { :primary => true } do filename = "/tmp/#{application}.dump.#{Time.now.to_f}.sql.bz2" text = capture "cat #{deploy_to}/#{shared_dir}/system/database.yml" yaml = YAML::load(text) on_rollback { delete filename } run "mysqldump -u #{yaml['production']['username']} -p #{yaml['production']['database']} | bzip2 -c > #{filename}" do |ch, stream, out| ch.send_data "#{yaml['production']['password']}\n" if out =~ /^Enter password:/ end `mkdir -p #{File.dirname(__FILE__)}/../backups` `rsync #{user}@#{roles[:db][0].host}:#{filename} #{File.dirname(__FILE__)}/../backups/` delete filename end
This paste will be private.
From the Design Piracy series on my blog: