#Geo/Map Server Migration #This is fairly simple to do and there's little risk. But be sure to have a backup of your production data directory anyway. #Just copy the following directories/files: #/workspaces/YOUR_WORKSPACE_NAME/ The workspace directory that you copy over actually contains the store and layer declarations as well as the workspace itself. Ideally in your setup you'll keep the "destined for production" and "testing" layers in separate workspaces, which will make this really easy in the future. cd /usr/local/geoserver/data_dir/workspaces rsync -az . maps.baydeltalive.com:/var/lib/geoserver_data/workspaces #/layergroups/your_layer_group.xml - If you have a layergroup you want to copy. cd /usr/local/geoserver/data_dir/layergroups rsync -az . maps.baydeltalive.com:/var/lib/geoserver_data/layergroups #styles\stylename.sld - styles\stylename.xml- This is the potentially tricky one; if you've renamed your style since you created it, the XML name and the SLD name won't be the same. The XML will be the current name, the SLD name will be whatever it was when you originally created it. You can look into the XML to see what SLD file it is referencing. cd /usr/local/geoserver/data_dir/styles rsync -az . maps.baydeltalive.com:/var/lib/geoserver_data/styles #data cd /usr/local/geoserver/data_dir/data rsync -az . maps.baydeltalive.com:/var/lib/geoserver_data/data #Copy physical data directorys < - > cd /var/www/html/maps rsync -az . maps.baydeltalive.com:/var/www/maps.baydeltalive.com/html/maps #Postgres - Dump - Restore < - > /usr/local/pgsql/bin/pg_dump -Fc explore_data > explore_data.sql /usr/local/pgsql/bin/pg_dump -Fc spatial > spatial.sql rsync -az explore_data.sql maps.baydeltalive.com:/usr/local/pgsql/data rsync -az spatial.sql maps.baydeltalive.com:/usr/local/pgsql/data #Once it's all copied, restart GeoServer. #apt-get --purge remove php5 php5-common php5-cli php5-gd #apt-get install libapache2-mod-php5 php5 php5-cli php5-common php5-json php5-pgsql php5-readline php5-xsl ####################################################### #upgrade POSTGRES #Following script here with modifications of versions and new Postgis Extensions method ... #https://wiki.debian.org/DebianGis/UpdatingPostGIS #and the postgis method: http://www.postgis.org/docs/postgis_installation.html#hard_upgrade ################### BACKUP OLD DBs ############################## #Create a "custom-format" dump of the database you want to upgrade (let's call it olddb) include binary blobs (-b) and verbose (-v) output. The user can be the owner of the db, need not be postgres super account. pg_dump -h localhost -p 5432 -U postgres -Fc -b -v -f "/somepath/olddb.backup" olddb pg_dump -h localhost -p 5432 -U postgres -Fc -b -v -f "./explore_data.dmp" explore_data pg_dump -h localhost -p 5432 -U postgres -Fc -b -v -f "./spatial.dmp" spatial ################### UNINSTALL OLD POSTGRESQL ################### #service postgresql stop #make uninstall if necessary #mv oldbindir psql.old ################### INSTALL ############################## aptitude install postgresql-9.4 postgresql-9.4-postgis-2.1 postgresql-9.4-postgis-2.1-scripts postgresql-9.4-postgis-scripts postgres=> alter user postgres password 'apassword'; postgres=> create user yerusername createdb createuser password 'somepass'; postgres=> create database yerusername owner yerusername; postgres=> \q #------------------------------------------------------------------------------ # FILE LOCATIONS #------------------------------------------------------------------------------ # The default values of these variables are driven from the -D command-line # option or PGDATA environment variable, represented here as ConfigDir. data_directory = '/var/lib/postgresql/9.4/main' # use data in another directory # (change requires restart) hba_file = '/etc/postgresql/9.4/main/pg_hba.conf' # host-based authentication file # (change requires restart) ident_file = '/etc/postgresql/9.4/main/pg_ident.conf' # ident configuration file ################### CREATE NEW DBs ############################## #2.6. Creating a spatial database using EXTENSIONS #If you are using PostgreSQL 9.1+ and have compiled and installed the extensions/ postgis modules, you can create a spatial database the new way. sudo -u postgres createdb development sudo -u postgres createdb dwrdata sudo -u postgres createdb explore_data sudo -u postgres createdb spatial createdb california #The core postgis extension installs PostGIS geometry, geography, raster, spatial_ref_sys and all the functions and comments with a simple: #CREATE EXTENSION postgis; #command. sudo -u postgres psql -d development -c "CREATE EXTENSION postgis;" sudo -u postgres psql -d dwrdata -c "CREATE EXTENSION postgis;" sudo -u postgres psql -d explore_data -c "CREATE EXTENSION postgis;" sudo -u postgres psql -d spatial -c "CREATE EXTENSION postgis;" sudo -u postgres psql -d california -c "CREATE EXTENSION postgis;" #Topology is packaged as a separate extension and installable with command: sudo -u postgres psql -d development -c "CREATE EXTENSION postgis_topology;" sudo -u postgres psql -d dwrdata -c "CREATE EXTENSION postgis_topology;" sudo -u postgres psql -d explore_data -c "CREATE EXTENSION postgis_topology;" sudo -u postgres psql -d spatial -c "CREATE EXTENSION postgis_topology;" sudo -u postgres psql -d california -c "CREATE EXTENSION postgis_topology;" #If you plan to restore an old backup from prior versions in this new db, run: #sudo -u postgres psql -d [yourdatabase] -f legacy.sql #You can later run uninstall_legacy.sql to get rid of the deprecated functions after you are done with restoring and cleanup. ################### RESTORE ############################## #Restore your backup into your fresh newdb database using postgis_restore.pl. Unexpected errors, if any, will be printed to the standard error stream by psql. Keep a log of those. sudo -u postgres perl /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_restore.pl "/var/local/postgres_bkup/development.dmp" | psql -h localhost -p 5432 -U postgres development 2> errors.txt perl /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_restore.pl "/var/local/postgres_bkup/development.dmp" | psql development 2> errors.txt perl /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_restore.pl "/var/local/postgres_bkup/dwrdata.dmp" | psql dwrdata 2> errors.txt perl /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_restore.pl "/var/local/postgres_bkup/explore_data.dmp" | psql explore_data 2> errors.txt perl /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_restore.pl "/var/local/postgres_bkup/spatial.dmp" | psql spatial 2> errors.txt perl /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_restore.pl "/var/local/postgres_bkup/california.dmp" | psql california 2> errors.txt #Reimport Stations