Last active
December 25, 2015 05:49
-
-
Save alnutile/6927783 to your computer and use it in GitHub Desktop.
Quick Script to automate the update of heroku db from dev to basic
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
site = ARGV[0] | |
if site | |
command = %x[heroku addons:add --app #{site} pgbackups] | |
puts "Added PgBackups" | |
command = %x[heroku addons:add --app #{site} heroku-postgresql:basic] | |
pg_info = %x[heroku pg:info --app #{site}] | |
pg_info_to_array = pg_info.split("\n") | |
db_row = pg_info[0].split(" ") | |
database_name = db_row[1] | |
command = %x[heroku maintenance:on --app #{site}] | |
puts "Maintenance mode on" | |
command = %x[heroku pgbackups:capture --app #{site} --expire] | |
puts "Backup Live DB" | |
command = %x[heroku pgbackups:restore --app #{site} #{database_name} --confirm #{site}] | |
puts "Restore to NEW db" | |
command = %x[heroku pg:promote --app #{site} #{database_name}] | |
puts "Promote DB" | |
command = %x[heroku maintenance:off --app #{site}] | |
puts "Site out of Maintenance mode http://#{site}.herokuapp.com" | |
else | |
puts "Oops you forgot to pass a site" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment