Module: PostgreSQL

Defined in:
lib/database/postgresql.rb

Instance Method Summary collapse

Instance Method Details

#backup(db_name) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/database/postgresql.rb', line 4

def backup(db_name)
  FileUtils::mkdir_p @path

  # Create a postgresql backup from the user supplied options
  system backup_db_command(db_name), out: File::NULL
rescue
  raise 'Unable to back up database'
end

#restore(db_name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/database/postgresql.rb', line 13

def restore(db_name)
  # Create the database to restore if it doesn't exist already
  system create_db_command(db_name), out: File::NULL

  # Restore the database from a backup
  system restore_db_command(db_name), out: File::NULL
rescue
  raise 'Unable to restore database'
end