Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload only one table using heroku pg:transfer instead of whole database

I'm able to push my database from my local machine to my heroku app with pg:transfer like this:

heroku pg:transfer --from postgres://localhost/idx_map_development --to aqua

But I don't want to upload the whole database, I only want to upload the properties table, is this possible using pg:transfer? If so how would the above line look?

like image 309
railsy Avatar asked Jun 04 '13 00:06

railsy


2 Answers

did it with pg_dump:

pg_dump -Fc --no-acl --no-owner -h localhost -U username -t properties idx_map_development > properties.dump

The file called properties.dump gets only the data for the properties table and I upload the file to an Amazon S3 bucket and can then push it to heroku with this:

heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/bucket_name/properties.dump'

The other tables on my heroku db are unaffected. You don't need to specify the properties table in the pgbackups:restore command.

like image 131
railsy Avatar answered Nov 03 '22 21:11

railsy


As was mentioned by @eugjill, this doesn't work anymore. So first you do the dump, as described by @railsy:

pg_dump -Fc --no-acl --no-owner -h localhost -U username -t properties idx_map_development > properties.dump

Then instead of using pgbackups, use the pg_restore:

PGPASSWORD=<PASSWORD> pg_restore --verbose --no-acl --no-owner -h <HOST> -U <USER> -d <DATABASE> -p <PORT> properties.dump
like image 27
Allie Hoch Janoch Avatar answered Nov 03 '22 20:11

Allie Hoch Janoch