Skip to content

Instantly share code, notes, and snippets.

View jmeiss's full-sized avatar

Jonathan Meiss jmeiss

View GitHub Profile
@JulienSansot
JulienSansot / app.json
Created June 16, 2017 16:22
heroku postdeploy script to copy PG database
{
"scripts": {
"postdeploy": "pg_dump -Fc $DATABASE_URL_TO_COPY | pg_restore --clean --no-owner -n public -d $DATABASE_URL && bundle exec rails db:migrate"
}
}
@ssaunier
ssaunier / db.rake
Last active January 8, 2021 11:46 — forked from abstractcoder/import.rake
Rake task to back up heroku database and restore it locally.
namespace :db do
desc "Backs up heroku database and restores it locally."
task import_from_heroku: [ :environment, :create ] do
HEROKU_APP_NAME = nil # Change this if app name is not picked up by `heroku` git remote.
c = Rails.configuration.database_configuration[Rails.env]
heroku_app_flag = HEROKU_APP_NAME ? " --app #{HEROKU_APP_NAME}" : nil
Bundler.with_clean_env do
puts "[1/4] Capturing backup on Heroku"
`heroku pg:backups capture DATABASE_URL#{heroku_app_flag}`
@JadedEvan
JadedEvan / s3cmd bucket to bucket copy
Created March 29, 2010 22:37
Copy files from one S3 bucket to another
#!usr/bin/env ruby
# This script takes a list of filenames from a given file and copies
# each of those files from one S3 bucket to another using the s3mcd library.
# Inputfile should have each filename termination by a newline character.
file, from, to = ARGV[0], ARGV[1], ARGV[2]
if file.nil? || from.nil? || to.nil?
puts "Invalid arguements. Should be filename from-s3-bucket to-s3-bucket"