Last active
February 24, 2016 21:21
-
-
Save isccarrasco/f828773d7ee628e86e8c to your computer and use it in GitHub Desktop.
Script that help to migrate a postgis database from an older versión (<= 9.3) to a new version ( >= 9.4) running on Mac OS X.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to migrate postgis | |
# Backup database | |
pg_dump -h localhost -p 5432 -U postgres -Fc -b -v -f "olddb.backup" db-name | |
# Create database | |
psql -c -U postgres "CREATE DATABASE db-name;" | |
# Apply postgis complements to the new database | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/postgis.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/spatial_ref_sys.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/postgis_comments.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/rtpostgis.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/raster_comments.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/topology.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/topology_comments.sql | |
psql -U postgres -d db-name -f /usr/local/Cellar/postgis/2.1.3/share/postgis/legacy.sql | |
# Restore oldest database content over the databse with new structure. | |
perl utils/postgis_restore.pl "/somepath/olddb.backup" | psql -h localhost -p 5432 -U postgres db-name 2> errors.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment