15

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?

2 Answers 2

14

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.

6
  • 2
    yet another trick if the migration of datastores and layers do not work, just empty the password tag in datastore.xml in each datastore folder, i had a bug when migrating from 2.8 to 2.9, because of a problem in the hash of the passwords.
    – geogeek
    Apr 25, 2017 at 21:27
  • I had to reapply the default style for layers that didn't have a custom style, but I didn't encounter any other problems.
    – Stijn
    Jul 6, 2017 at 11:54
  • @geogeek it's also possible to replace the strings like crypt2:YOUR_ENCRYPTED_PASSWORD_HERE with plain:YOUR_PASSWORD_HERE. This is not generally recommended but can be useful for testing and experiments. Dec 11, 2019 at 4:06
  • I have applied same instruction with geoserver 2.15 , I can see workspace and stores but the layers are not coming? What am I doing wrong?
    – ncelik
    Dec 13, 2019 at 11:44
  • As a followup, adding the plain: prefix in a "datastore.xml"-file will tell Geoserver to keep the password plain. If there is no prefix (just the password itself), Geoserver will actually obfuscate the password in the file when the settings are next saved. I'm not sure what happens in this case if the password itself has a : (colon) in it Dec 14, 2019 at 0:35
1

You copy&paste workspaces (Your Projects) in following path C:\ProgramData\Boundless\OpenGeo\geoserver\workspaces Than restart Geoserver

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.