Created
July 28, 2010 17:16
-
-
Save champierre/495370 to your computer and use it in GitHub Desktop.
This file contains 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
namespace :myapp do | |
desc 'Captures a heroku bundle and downloads it. The downloaded files are stored in backups/' | |
task :backup do | |
app_name = RAILS_ROOT.split('/').last | |
timestamp = `date -u '+%Y-%m-%d-%H-%M'`.chomp | |
bundle_name = "#{app_name}-#{timestamp}" | |
puts "Capturing bundle #{bundle_name}..." | |
`heroku bundles:capture --app #{app_name} '#{bundle_name}'` | |
# poll for completion (warning, a little hacky) | |
begin | |
bundles = `heroku bundles --app #{app_name}` | |
end while bundles.match(/complete/).nil? | |
# download & destroy the bundle we just captured | |
%w(download destroy).each do | action | | |
`heroku bundles:#{action} --app #{app_name} '#{bundle_name}'` | |
end | |
`mv #{app_name}.tar.gz backups/#{bundle_name}.tar.gz` | |
puts "Bundle captured and stored in backups/#{bundle_name}.tar.gz" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment