[postgis-users] postgis introduction data bundle can not restore a backup.

238 views
Skip to first unread message

Jian He

unread,
Apr 13, 2022, 5:31:51 AM4/13/22
to postgi...@lists.osgeo.org

I use the follow command to restore a database.

pg_restore -h localhost -p 5432 -U jian -d postgis_in_action nyc_data.backup

I cannot load the backup file to database.
Too many errors like :

 ERROR:  type "public.geometry" does not exist
 ERROR:  relation "public.nyc_census_blocks" does not exist

There is only another .sql file. But the file only have one table: nyc_census_sociodata

where can I get the table create script. 

Imre Samu

unread,
Apr 13, 2022, 8:17:44 AM4/13/22
to PostGIS Users Discussion
> 5. Loading spatial data — Introduction to PostGIS
> ERROR:  type "public.geometry" does not exist

as I see in the  "4. Creating a Spatial Database"  https://postgis.net/workshops/postgis-intro/creating_db.html 
there are 2 important step
- create Username as postgres.   
- "CREATE EXTENSION postgis;"

and the restore should work.
if you see an error like "ERROR:  duplicate key value violates unique constraint "nyc_census_blocks_pkey""
you have to use "-c"  option
"    -c, --clean                  clean (drop) database objects before recreating"
add sometimes the "--verbose" option is also useful. 


regards,
 Imre




_______________________________________________
postgis-users mailing list
postgi...@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

Jian He

unread,
Apr 13, 2022, 11:51:53 PM4/13/22
to PostGIS Users Discussion

Thanks.  Problem solved. 
Reply all
Reply to author
Forward
0 new messages