Last active
December 25, 2015 07:28
-
-
Save teeparham/6939017 to your computer and use it in GitHub Desktop.
Upgrade from Postgres 9.2 to 9.3 and PostGIS 2.0 to 2.1. OSX, homebrew
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
| create extension postgis; | |
| create extension postgis_topology; | |
| alter extension postgis update to "2.1.0"; |
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
| # in this example, the old 9.2/2.0 database is "db20" & the new 9.3/2.1 database is "db21" | |
| # backup old database | |
| pg_dump -Fc -b -v -f "db20.bak" db20 | |
| # install latest postgis 2.1, which includes postgresql 9.3 | |
| brew update | |
| brew uninstall geos postgis postgresql | |
| brew install postgis | |
| # backup 9.2 data directory | |
| mv /usr/local/pgsql/data /usr/local/pgsql/data92 | |
| # initialize a new 9.3 data directory | |
| mkdir /usr/local/pgsql/data | |
| initdb -D /usr/local/pgsql/data | |
| # start database | |
| postgres -D /usr/local/pgsql/data | |
| # default all new postgres databases to be postgis databases | |
| cat postgis_21_ext.sql | psql -d template1 | |
| # new database will use the template for postgis & have the extension installed | |
| createdb db21 | |
| # load backed up 2.0 data into new 2.1 db, stripping out 2.0 tables and functions | |
| perl /usr/local/Cellar/postgis/2.1.0/share/postgis/postgis_restore.pl db20.bak | psql db21 2> errors.txt | |
| # references | |
| # http://www.postgresql.org/docs/9.3/static/upgrading.html | |
| # http://postgis.net/docs/postgis_installation.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment