Skip to content

Instantly share code, notes, and snippets.

View zanloy's full-sized avatar

Zan Loy zanloy

  • Charleston, SC
View GitHub Profile
@zanloy
zanloy / db.rake
Created March 11, 2017 14:13 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd