Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- APP_DIR = ARGV[0]
- BACKUP_DIR = ARGV[1]
- # run a command from your app's root directory
- def cmd(str)
- return `cd #{APP_DIR}; #{str}`.sub(10.chr, '')
- end
- puts('* Determining bundle status...')
- status = cmd('heroku bundles')
- unless status.index("has no bundles.").nil?
- # No bundle currently exists, so have Heroku create one
- puts('*** Capturing bundle because none exist...')
- capture = cmd('heroku bundles:capture')
- else
- bundle_name = status.split.first
- unless status.index('complete').nil?
- puts('*** Bundle was captured successfully')
- puts('* Downloading bundle...')
- download = cmd('heroku bundles:download')
- puts("*** Moving #{bundle_name} to backup location...")
- filename = download.split.last
- newname = "#{bundle_name} (#{Time.now.strftime('%Y-%m-%d %H%M%S')}).tar.gz"
- move = `mv #{APP_DIR}/#{filename} "#{BACKUP_DIR}/#{newname}"`
- puts('*** Destroying remote bundle...')
- destroy = cmd("heroku bundles:destroy #{bundle_name}")
- puts('* Done')
- end
- unless status.index('capturing').nil?
- puts('*** Still capturing. Try again in a bit...')
- end
- end
Add Comment
Please, Sign In to add comment