I'm supposed to seed the partial data from existing Postgres DB residing on Server A into another Postgres DB residing on Server B. Is there any efficient way to do so apart from creating the API and executing in a Rake Task or using seeds.rb?
More Details
I tried the approach suggested by @Siim Liiser, but it creates the dump of all the data in the table instead of selected records. Is there any way to add a where clause in dump option?
Use
pg_dumpto store data fromServer Ainto a file. There's plenty of options to choose which partial data you want to export. Most useful is probably to specify which tables you want.Move that file over to
Server B(scpor whatever other tool you wish to use) and thenpg_restoreit into the database onServer B.This is the best solution for a simple one time action in my opinion. Of course building an api for this would also work, but would be more work and slower to execute.