2011年10月26日 星期三

PostGIS 1.3x to 1.5x 的完美升級方法

之前有發表過一篇PostGIS的升級方法,那是參考postgis網站的說明文件來升級的,相信只要做過的人一定會發覺過程中有些不知道該怎麼解決的錯誤訊息,雖然整個跑完資料庫還是會建立起來,但是心中難免會毛毛的.....

經過我跟postgis幾番的奮戰之後,終於發現可以沒有錯誤訊息的完美升級(搬移)方式
首先要先dump舊的PostGIS資料庫
 sudo -u postgres pg_dump -Fc old_postgis_db old_postgis_db_dumpfile

之後在新的PostgreSQL伺服器上建立資料庫
sudo -u postgres createdb your_postgis_db
sudo -u postgres createlang plpgsql your_postgis_db
sudo -u postgres psql -d your_postgis_db -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
sudo /usr/share/postgresql-8.4-postgis/utils/new_postgis_restore.pl old_postgis_db_dumpfile | sudo -u postgres psql your_postgis_db

這樣就可以無錯誤訊息的將PostGIS 1.3的資料庫升級(搬移)至PostGIS 1.5x的資料庫上了。