PostgreSQL Database resources protect a PostgreSQL database instance by managing the PostgreSQL service during failover and failback operations.
Resource Type: database/pgsqlapp
Aliases: pgsqlapp, pgsql
Preconditions
- PostgreSQL must be installed on the server.
- The PostgreSQL service (Windows) or service name must exist and be accessible.
- A PostgreSQL database user account must be available for health checks.
Subcommands
PostgreSQL Database resources are managed by commands of the form:
lkcli resource database/pgsqlapp <subcommand> [flags]
| Subcommand | Description | Required Role |
|---|---|---|
create
|
Create a new PostgreSQL resource | admin |
extend
|
Extend to a standby server | admin |
get-property
|
Read a resource property | guest |
set-property
|
Update an editable resource property | admin |
create
lkcli resource database/pgsqlapp create \
--db-user=<string> --service-name=<string> [flags]
| Flag | Short | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|---|
--db-user
|
— | string | Yes | — | — | PostgreSQL user for health check connections |
--service-name
|
— | string | Yes | — | — | OS service name for PostgreSQL |
--data-dir
|
— | string | No | — | — | Full path to PostgreSQL data directory |
--exe-dir
|
— | string | No | — | — | Full path to PostgreSQL executable directory |
--port
|
— | int | No | — | — | PostgreSQL listening port |
--service-username
|
— | string | No | — | — | Windows service account username |
--service-password
|
— | string | No | — | — | Windows service account password |
--tag
|
— | string | No | Auto-generated | — | Resource tag name |
--switchback
|
— | enum | No | INTELLIGENT
|
INTELLIGENT, AUTOMATIC
|
Switchback type |
--deepcheck-interval
|
— | int | No | 300
|
min: 0, max: 604800 | Deepcheck interval in seconds (Windows only) |
--quickcheck-interval
|
— | int | No | 180
|
min: 0, max: 604800 | Quickcheck interval in seconds |
extend
lkcli resource database/pgsqlapp extend --primary-sys=<string> --primary-tag=<string> [flags]
| Flag | Short | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|---|
--primary-sys
|
— | string | Yes | — | — | Hostname of the server the existing resource is extended from |
--primary-tag
|
— | string | Yes | — | — | Tag of the existing resource to extend |
--standby-sys
|
— | string | No | Value of --host (defaults to localhost)
|
— | Hostname of the standby server |
--exe-dir
|
— | string | No | — | — | Override PostgreSQL executable directory on standby |
--service-username
|
— | string | No | — | — | Windows service account username on standby |
--service-password
|
— | string | No | — | — | Windows service account password on standby |
--switchback
|
— | enum | No | INTELLIGENT
|
INTELLIGENT, AUTOMATIC
|
Switchback type |
--primary-priority
|
— | int | No | Defaults to the current priority of the --primary-sys server, or 1 if the resource has not yet been extended
|
min: 1, max: 999 | Failover priority for the primary server |
--standby-priority
|
— | int | No | Defaults to an unused value which is computed dynamically based on the priority values currently in-use | min: 1, max: 999 | Failover priority for the standby server |
get-property / set-property
lkcli resource database/pgsqlapp get-property --tag=<string> --property=<string>
lkcli resource database/pgsqlapp set-property --tag=<string> --property=<string> --value=<string>
| Flag | Short | Type | Required | Description |
|---|---|---|---|---|
--tag
|
-t
|
string | Yes | Resource tag name |
--property
|
-p
|
string | Yes | Property name (see Properties table below) |
--value
|
-v
|
string | Yes (set-property only)
|
New property value |
Properties
| Property | Type | Constraints | Editable | Description |
|---|---|---|---|---|
service-name
|
string | — | No | OS service name for PostgreSQL |
db-user
|
string | — | No | PostgreSQL user for health check connections |
data-dir
|
string | — | No | Full path to PostgreSQL data directory |
exe-dir
|
string | — | No | Full path to PostgreSQL executable directory |
port
|
int | — | No | PostgreSQL listening port |
created-service
|
int | — | No | Whether LifeKeeper created the PostgreSQL service (0=false, 1=true) |
kit-name
|
string | — | No | Recovery kit name |
deepcheck-interval
|
int | min: 0, max: 604800 | Yes | Deepcheck interval in seconds (default: 300) |
quickcheck-interval
|
int | min: 0, max: 604800 | Yes | Quickcheck interval in seconds (default: 180) |
local-recovery
|
enum | enabled, disabled
|
Yes | Enable local recovery |
switchback
|
enum | INTELLIGENT, AUTOMATIC
|
Yes | Switchback type |
Example Usage
# Create a PostgreSQL resource
lkcli resource database/pgsqlapp create \
--host=server1 \
--db-user=postgres \
--service-name=postgresql-16 \
--port=5432 \
--data-dir="D:\pgdata" \
--tag=pgsql.0
# Extend to server2
lkcli resource pgsql extend \
--primary-sys=server1 \
--primary-tag=pgsql.0 \
--standby-sys=server2



Post your comment on this topic.