Guest User

Untitled

a guest
Jun 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1.  
  2. APP_DIR = ARGV[0]
  3. BACKUP_DIR = ARGV[1]
  4.  
  5. # run a command from your app's root directory
  6. def cmd(str)
  7. return `cd #{APP_DIR}; #{str}`.sub(10.chr, '')
  8. end
  9.  
  10. puts('* Determining bundle status...')
  11. status = cmd('heroku bundles')
  12.  
  13. unless status.index("has no bundles.").nil?
  14. # No bundle currently exists, so have Heroku create one
  15. puts('*** Capturing bundle because none exist...')
  16. capture = cmd('heroku bundles:capture')
  17. else
  18.  
  19. bundle_name = status.split.first
  20.  
  21. unless status.index('complete').nil?
  22. puts('*** Bundle was captured successfully')
  23. puts('* Downloading bundle...')
  24.  
  25. download = cmd('heroku bundles:download')
  26.  
  27. puts("*** Moving #{bundle_name} to backup location...")
  28. filename = download.split.last
  29. newname = "#{bundle_name} (#{Time.now.strftime('%Y-%m-%d %H%M%S')}).tar.gz"
  30.  
  31. move = `mv #{APP_DIR}/#{filename} "#{BACKUP_DIR}/#{newname}"`
  32.  
  33. puts('*** Destroying remote bundle...')
  34. destroy = cmd("heroku bundles:destroy #{bundle_name}")
  35.  
  36. puts('* Done')
  37.  
  38. end
  39.  
  40. unless status.index('capturing').nil?
  41. puts('*** Still capturing. Try again in a bit...')
  42. end
  43.  
  44. end
Add Comment
Please, Sign In to add comment