Module: Rumination::Pg::Commands

Defined in:
lib/rumination/pg/commands.rb

Overview

include this module into something with #sh, e.g. next to Rake::FileUtils

Instance Method Summary collapse

Instance Method Details

#create_dump(path, *args) ⇒ Object



21
22
23
24
# File 'lib/rumination/pg/commands.rb', line 21

def create_dump path, *args
  args = Pg.config.create_dump_args + args + %W[--file=#{path}]
  sh "pg_dump #{args.join(" ")}"
end

#load_dump(path, *args) ⇒ Object



26
27
28
29
# File 'lib/rumination/pg/commands.rb', line 26

def load_dump path, *args
  args = Pg.config.load_dump_args + args
  sh "gunzip -c #{path} | psql #{args.join(" ")}"
end

#pg_restore(*args) ⇒ Object



13
14
15
# File 'lib/rumination/pg/commands.rb', line 13

def pg_restore *args
  Pg::Restore.call *args, "-d", ENV["PGDATABASE"]
end

#rsync(*args) ⇒ Object



17
18
19
# File 'lib/rumination/pg/commands.rb', line 17

def rsync *args
  sh "rsync #{args.join(" ")}"
end