Datastore Commands#
Manage GeoServer datastores. Datastores define connections to data sources like PostGIS, Shapefiles, or other spatial databases.
List Datastores#
List all datastores in a workspace.
1
2
3
4
5
| # Using default workspace
./geoserver-cli store list
# Specify workspace
./geoserver-cli store list -w my_workspace
|
Output:
1
2
| postgis_store
shapefile_store
|
Get Datastore#
Get detailed information about a datastore (returns raw JSON).
1
| ./geoserver-cli store get postgis_store -w my_workspace
|
Create Datastore#
Create a new datastore with connection parameters.
PostGIS Datastore#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # Create connection parameters file
cat > postgis_params.json <<EOF
{
"dbtype": "postgis",
"host": "localhost",
"port": 5432,
"database": "gis",
"user": "postgres",
"passwd": "password",
"schema": "public"
}
EOF
# Create datastore
./geoserver-cli store create postgis_store -w my_workspace --params @postgis_params.json
|
From Stdin#
1
2
| echo '{"dbtype":"postgis","host":"localhost","port":5432,"database":"gis","user":"postgres","passwd":"password"}' | \
./geoserver-cli store create postgis_store -w my_workspace --params -
|
Inline JSON#
1
2
| ./geoserver-cli store create postgis_store -w my_workspace \
--params '{"dbtype":"postgis","host":"localhost","port":5432,"database":"gis","user":"postgres","passwd":"password"}'
|
Update Datastore#
Update connection parameters for an existing datastore.
1
2
3
4
5
| # Update from file
./geoserver-cli store update postgis_store -w my_workspace --params @updated_params.json
# Update from stdin
cat updated_params.json | ./geoserver-cli store update postgis_store -w my_workspace --params -
|
Delete Datastore#
Delete a datastore. Requires --yes flag.
1
| ./geoserver-cli store delete postgis_store -w my_workspace --yes
|
!!! warning “Deletion is Permanent”
Deleting a datastore removes all associated layers. This action cannot be undone.
Connection Parameters#
Common connection parameter formats:
PostGIS#
1
2
3
4
5
6
7
8
9
10
| {
"dbtype": "postgis",
"host": "localhost",
"port": 5432,
"database": "gis",
"user": "postgres",
"passwd": "password",
"schema": "public",
"Expose primary keys": true
}
|
Shapefile Directory#
1
2
3
| {
"url": "file:///path/to/shapefiles"
}
|
Directory of Spatial Files#
1
2
3
| {
"url": "file:///path/to/directory"
}
|
Examples#
Complete PostGIS Setup#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| # 1. Create workspace
./geoserver-cli workspace create my_workspace
# 2. Create PostGIS datastore
cat > pg_conn.json <<EOF
{
"dbtype": "postgis",
"host": "db.example.com",
"port": 5432,
"database": "gis",
"user": "geoserver",
"passwd": "secure_password",
"schema": "public"
}
EOF
./geoserver-cli store create postgis -w my_workspace --params @pg_conn.json
# 3. Verify
./geoserver-cli store list -w my_workspace
|
Update Connection Password#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # Create updated params with new password
cat > pg_conn_new.json <<EOF
{
"dbtype": "postgis",
"host": "db.example.com",
"port": 5432,
"database": "gis",
"user": "geoserver",
"passwd": "new_secure_password",
"schema": "public"
}
EOF
# Update datastore
./geoserver-cli store update postgis -w my_workspace --params @pg_conn_new.json
|