Created
November 11, 2008 19:12
-
-
Save febuiles/23936 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Backup database | |
| namespace :db do | |
| desc "Backup the remote production database" | |
| task :backup, :roles => :db, :only => { :primary => true } do | |
| mysql_password = Capistrano::CLI.password_prompt("Production MySQL password: ") | |
| timestamp_string = Time.now.strftime("%Y%m%d%H%M%S") | |
| filename = "#{application}.dump.#{timestamp_string}.sql.bz2" | |
| file = "/tmp/#{filename}" | |
| on_rollback { "rm -f #{file}" } | |
| run "mysqldump -u #{user} --password=#{mysql_password} vom_production | bzip2 -c > #{file}" do |ch, stream, data| | |
| puts data | |
| end | |
| `mkdir -p #{File.dirname(__FILE__)}/../backups/` | |
| download file, "backups/#{filename}" | |
| "rm -f #{file}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment