This image syncs a local geoserver datadir with a remote git repository, for backup purposes
2.3K
This repository is the source of the camptocamp/geoserver-datadir-sync image on Docker Hub.
The image provides an easy way to git commit the content of geoserver datadir every time the global.xml file is updated.
This image expects to find the datadir volume mounted in rw mode on /var/local/data.
The file to watch for changes should also be contained in this directory.
Internally, we're using inotifywait to watch the file.
When change is detected, the script performs the commit and optionally pushes to a remote repository.
At startup, if a remote repository is configured a clone of this repository is
done in the volume. If volume is not empty, you will need to set FORCE_CLONE var
to 'yes' to force a cleanup of the volume. If the volume is already verionned
(contains a .git folder) then git remote is updated and local repository is updated
to the last commit of configured branch.
Example usage:
sync:
image: camptocamp/geoserver-datadir-sync
environment:
WATCH_FILE: global.xml
GIT_COMMIT_MESSAGE: printf "updateSequence "; grep updateSequence global.xml|sed -e 's#.*ce>\(.*\)</up.*#\1#'
GIT_USERNAME: fvanderbiest
GIT_EMAIL: [email protected]
volumes:
- geoserver_datadir:/var/local/data:rw
If WATCH_FILE environment is not set, volume will only be bootstraped from
remote git repository. Note that entrypoint will stop just after volume
bootstrap so you should configure container restart policy.
Required environment for watching:
WATCH_FILE: file to watch (path relative to volume root)GIT_COMMIT_MESSAGE: string or expression evaluated in the volume to provide a commit messageGIT_USERNAME: git username for commitGIT_EMAIL: git email for commitTo push to a repository, these additional variables are required:
REMOTE_NAME: name of the git remote, eg originREMOTE_URL: git repository URLOptional environment:
REMOTE_BRANCH: Remote branch to use. Defaults to master.FORCE_CLONE: Delete volume content before cloning remote repositoryTo use SSH authentication to access remote repository, one of following variables must be set:
GIT_RSA_DEPLOY_KEY: Private RSA key to use (eg: GitHub deploy keys)GIT_RSA_DEPLOY_KEY_FILE: Path to a file containing the private RSA key to useWARNING: the git push command performs a forced update to the master branch, which might result in data loss !
Optional:
SLEEPING_TIME: if WATCH_FILE does not exist at startup, time to wait before a new check starts. Defaults to 1 sec.In the tests folder there's a docker-compose file to easily create a testing environment.
The Dockerfile in the tests/geoserver_mock directory creates an image whose purpose is to periodically update the contents of a docker volume.
It kind of mimics what GeoServer does to its config directory and is a lightweight alternative.
Content type
Image
Digest
sha256:38a38d4e4…
Size
85.8 MB
Last updated
about 2 years ago
docker pull camptocamp/geoserver-datadir-sync