I have a dump of a postgis layer (layer.dump), which I am trying to add to my heroku database (mydatabase). The postgis layer is stored on S3 (https://s3.amazonaws.com/layer.dump). I would like to add the layer to to the heroku database and previously used heroku pgbackups:restore DATABASE 'https://s3.amazonaws.com/layer.dump'
. However, the new heroku pg:backups restore 'https://s3.amazonaws.com/layer.dump' DATABASE
deletes all data from the target database before restoring the backup (https://devcenter.heroku.com/articles/heroku-postgres-backups). Is there still a way to only restore a single table and leave the remaining tables in the database untouched?
Postgresql – Copy postgis layer from S3 to Heroku
awsherokupostgispostgresqlrestore
Related Question
- Postgresql – Postgres Restore Not Restoring Bytea Data
- PostgreSQL Migration – Challenges from Postgres 8.1 to 9.4 with PostGIS
- Sql-server – Change the database from restoring state to standby mode
- PostGIS DB Dump/Restore Errors on EC2 to RDS – Solutions
- SQL Server – How to Restore File Group from File Group Backup?
- SQL Server 2017 – How to Perform Piecemeal Restore of One Filegroup Without Primary Filegroup
- Postgresql – pg_restore using PostGIS/PostgreSQL Dump Changes Data in Geography Column
Best Answer
According to the link to a Heroku discussion here: Howto: Restore a single table to an existing database, the way your're doing it is always a destructive action.
A better solution proposed is to dump the table locally, and import the data remotely.
You could do a single dump of the table using a command like this:
And then try to restore it like this:
If you need a more intricate restore, I would recommend using
pg_dump
from the originating database with the-Fc
flag, like this:And then using the
pg_restore
utility to restore just the parts you need.Further documentation for pg_restore is here: http://www.postgresql.org/docs/9.4/static/app-pgrestore.html
And for pg_dump: http://www.postgresql.org/docs/9.4/static/app-pgdump.html
Hope that helps. =)