Last active
August 29, 2015 14:21
-
-
Save pvcarrera/e554db225ba7b0386384 to your computer and use it in GitHub Desktop.
Heroku Rake tasks
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 :heroku do | |
DEFAULT_APP = 'my_app' | |
desc 'Create database backup' | |
task :backup, :app do |task, args| | |
args.with_defaults(app: DEFAULT_APP) | |
Bundler.with_clean_env do | |
`heroku pg:backups capture --app #{args[:app]}` | |
end | |
puts $?.exitstatus == 0 ? 'Backup created.' : 'Backup failed.' | |
end | |
desc 'Download latest database backup' | |
task :download_backup, :app do |task, args| | |
args.with_defaults(app: DEFAULT_APP) | |
Bundler.with_clean_env do | |
url = `heroku pg:backups public-url --app #{args[:app]}` | |
`curl -o latest.dump "#{url}"` | |
end | |
puts $?.exitstatus == 0 ? 'Database downloaded.' : 'Download failed.' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment