Skip to content

Commit a0fc6dd

Browse files
committed
use different location for pgpass on splunk 10.0
1 parent 9ae3acc commit a0fc6dd

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

splunkconf-backup/bin/splunkconf-backup.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ exec > /tmp/splunkconf-backup-debug.log 2>&1
160160
# 20260324 update condition fro unconfigured s3
161161
# 20260326 add test entry in kvstore collection so it can be used for testing
162162
# 20260330 add check for postgres
163+
# 20260403 use different location for pgpass on splunk 10.0
163164

164-
VERSION="20260330a"
165+
VERSION="20260403a"
165166

166167
###### BEGIN default parameters
167168
# dont change here, use the configuration file to override them
@@ -1896,9 +1897,19 @@ if [ "$MODE" == "0" ] || [ "$MODE" == "pg" ]; then
18961897
#echo ""
18971898
debug_log "--- Checking for Postgres credentials file ---"
18981899
if test -f ${SPLUNK_HOME}/var/packages/data/postgres/.pgpass 2>/dev/null; then
1900+
# Splunk 10.2+
18991901
PGPASS_FILE="${SPLUNK_HOME}/var/packages/data/postgres/.pgpass"
19001902
debug_log "Found .pgpass in packages/data/postgres directory"
1901-
1903+
elif test -f ${SPLUNK_HOME}/var/packages/data/postgres/db/.pgpass 2>/dev/null; then
1904+
# Splunk 10.0
1905+
PGPASS_FILE="${SPLUNK_HOME}/var/packages/data/postgres/db/.pgpass"
1906+
debug_log "Found .pgpass in packages/data/db/postgres directory"
1907+
else
1908+
debug_log "❌ ERROR No .pgpass file found"
1909+
fi
1910+
if [ -z ${PGPASS_FILE+x} ]; then
1911+
debug_log "no pg pass"
1912+
else
19021913
# Attempt to verify Postgres connectivity (if psql is available)
19031914
echo "--- Attempting Postgres connectivity check ---"
19041915
if test -x ${SPLUNK_HOME}/bin/psql 2>/dev/null; then
@@ -1923,11 +1934,8 @@ if [ "$MODE" == "0" ] || [ "$MODE" == "pg" ]; then
19231934
warn_log "❌ ERROR: psql binary not found at ${SPLUNK_HOME}/bin/psql — skipping direct connectivity test"
19241935
fi
19251936

1926-
# fi
1937+
fi # if pgpass_file
19271938

1928-
else
1929-
echo "❌ ERROR No .pgpass file found"
1930-
fi
19311939
fi #BACKUPPG
19321940
fi # mode
19331941

0 commit comments

Comments
 (0)