1

I am working with a Rails 4 app, I am using PSQL both in my development and production. Due to some reason I have to work with a new computer/laptop so I set up Rails environment in it and cloned my app into it, but what I really require is that, I need my existing databse with data in it, how to do it ?

Praveen George
  • 9,237
  • 4
  • 26
  • 53

1 Answers1

1

To do this you need to create a dump on system 1 and restore it on system 2, here are the steps:

  1. sudo -u postgres pg_dump <DB_NAME> > dump - creating a file dump
  2. Copy this file via dropbox or whatever to another system.
  3. sudo -u postgres psql <DB_NAME> < dump - copy the new created dump to new system.

Note:

You should have empty created database on your new system, or you can use dataonly dump passing the --data-only to pg_dump command. Also you can read documentation for pg_dump to find any other options which you might need.

Community
  • 1
  • 1
mpospelov
  • 1,510
  • 1
  • 15
  • 24