For importing or ingesting GIS shapefile to a postgresql database we can use shp2pgsql command, example:
shp2pgsql -s 4326 -c -D -I myshapefile dbtable | \
psql -d dbname -h localhost -p 5432 -U dbuser
In example above we convert or import the shapefile (myshapefile) to dbtable in dbname database with a dbuser.
-s: SRID
-c: Creates a new table and populates it, default if you do not specify any options.
-D: Use postgresql dump format (defaults to sql insert statments).
-I: Create a GiST index on the geometry column.
-h: database hostname
-p: database port name
-U: database user
For exporting a postgres table to shapefile we use pgsql2shp:
pgsql2shp -f “myshapefile” -h localhost -u dbuser dbname dbtable
-f: shape file name
-h: database hostname
-u: database user