6

is it possible to export layer configurations from geoserver and import them into geoserver on another computer? It takes a long time to keep setting up the layers everytime i switch computers.

MBU
  • 4,998
  • 12
  • 59
  • 98

4 Answers4

9

Apparently you cant..The only way is to copy the data_dir directory and replace the new installations data_dir. Then when you start up geoserver the layer configs you setup should load automatically.

MBU
  • 4,998
  • 12
  • 59
  • 98
  • 1
    On a machine with new install of geoserver layers with encrypted passwords stored in the data_dir will not load correctly. – whatnick Nov 29 '17 at 23:20
  • "Should" being the operative word. I have had lots of issues over the years with this. Always make a basic "copy" backup before upgrading. I have also started using multiple instances each with their own subset of layers. Minor errors seem to build up over time and when frequently editing lots of layers, it can be hard to narrow down to a single problematic one. With small instances, it is not a big deal to bring them in one at a time to a new instance and then destroy the old. – Kevin Aug 04 '20 at 14:29
2

You could use the Geoserver Manager1 (a wrapper around the Geoserver rest-api), to configure your layers, and store the procedure. Then you could just point the Manager to the new Geoserver.

1

For the migration of Geoserver 2.x to Geoserver 2.y (using Tomcat):

  1. Make a backup of your directory "data" of Geoserver 2.x.

  2. Stop Geoserver 2.x in Tomcat and then, stop Tomcat (sudo /etc/init.d/tomcatx stop).

  3. Remove (a backup is best) your directory "geoserver" of "webapps". (generally is tomcatx/webapps).

  4. Install the new version of Geoserver (in this case Geoserver 2.y). If you are using Tomcat, you could use the war file.

  5. Edit the file "web.xml" (tomcatx/webapps/geoserver/WEB-INF/web.xml) whit the new path. For example:

    <context-param>
        <param-name>GEOSERVER_DATA_DIR</param-name>
        <param-value>/var/lib/tomcatx/webapps/geoserver/data</param-value>
    </context-param> 
    

to

    <context-param>
        <param-name>GEOSERVER_DATA_DIR</param-name>
        <param-value>new-path-of-data</param-value>
    </context-param> 
  1. Move your new directory "security" to other place (usually is tomcatx/webapps/geoserver/data/security).

  2. Change permissions of your data directory to tomcatx. (chgrp, chown)

  3. Restart Tomcat.

Regards.

Geoserver 2.x is old version.

Geoserver 2.y is new version.

tomcatx is your version of Tomcat.

0
1.copy folder "data" in geoserver to on another computer and replace it to .war and geoserver folder

2-dump database old to new computer 

3-restart tomcat

/etc/init.d/tomacat7 restrat

4-change owner "data" on geoserver to  tomcat user 

-cd to /var/lib/tomcat7/webapps/geoserver sudo chown -R tomcat7 data sudo chown -R :tomcat7 data

5-reload store on geoserver