Method: Thredded::DbTools.dump

Defined in:
lib/thredded/db_tools.rb

.dump(to = dump_file) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/thredded/db_tools.rb', line 27

def dump(to = dump_file)
  case adapter
  when /sqlite/i
    system ['sqlite3', Rails.root.join(database), '.dump', '>', to].join(' ')
  when /postgres/i
    cmd = "pg_dump --dbname=postgresql://#{username}:#{password}@#{host}:5432/#{database}" \
      "--verbose --clean --no-owner --no-acl --format=c > #{to}"
    system cmd
  when /mysql/i
    system("mysqldump --user #{username} -p#{password} #{database} > #{to}")
  end
end