[GIS] How to migrate a specific workspace, store and layer in Geoserver

deploymentgeoservermigration

Geoserver is running on a development and production environment. I would like to migrate just one workspace, store, layer, style, etc from development to production. How can I do this?

I know I can copy the entire data-dir to production and restart geoserver; but than all workspaces, stores, etc are migrated. The point is I want just one workspace, store, etc.

In the development environment I have several test workspace, store, and layers, which I do not want on production.

In the data-dir I see a directory gwc-layers, with a lot of xml-files. But how do I know which xml is which layer?

Best Answer

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.

/layergroups/your_layer_group.xml - If you have a layergroup you want to copy.

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.

Once it's all copied, restart GeoServer.

Using this method I've previously manually transferred dozens of layers and a 200+ styles with little trouble.

Related Question