File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 388388 fi
389389
390390 log " INFO" " Pgbackrest stanza created successfully"
391+
392+ # Now update the archive_command to use pgbackrest
393+ log " INFO" " Updating archive_command in postgresql.conf..."
394+ local pgdata=" ${PGDATA:-/ var/ lib/ postgresql/ data} "
395+
396+ # Update the archive_command to use pgbackrest
397+ sed -i " s|archive_command = '/bin/true'|archive_command = 'pgbackrest --stanza=${stanza_name} archive-push %p'|g" " $pgdata /postgresql.conf"
398+
399+ # Reload PostgreSQL configuration
400+ log " INFO" " Reloading PostgreSQL configuration..."
401+ su-exec postgres pg_ctl reload -D " $pgdata "
402+
403+ # Verify the archive_command was updated
404+ log " INFO" " Verifying archive_command configuration..."
405+ archive_cmd_check=$( su-exec postgres psql -d " $pg_database " -t -c " SHOW archive_command;" 2> /dev/null | sed ' s/^[ \t]*//;s/[ \t]*$//' )
406+ log " INFO" " Current archive_command: $archive_cmd_check "
407+
391408 return 0
392409}
393410
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ start_postgresql() {
6969 # Enable WAL archiving for pgBackRest (CRITICAL for backup functionality)
7070 echo " wal_level = replica" >> " $PGDATA /postgresql.conf"
7171 echo " archive_mode = on" >> " $PGDATA /postgresql.conf"
72- echo " archive_command = 'pgbackrest --stanza=${PGBACKREST_STANZA:- main} archive-push %p'" >> " $PGDATA /postgresql.conf"
72+ # Initially disable archive_command until stanza is created
73+ echo " archive_command = '/bin/true'" >> " $PGDATA /postgresql.conf"
7374 echo " max_wal_senders = 3" >> " $PGDATA /postgresql.conf"
7475 echo " wal_keep_size = 1GB" >> " $PGDATA /postgresql.conf"
7576
@@ -163,7 +164,7 @@ EOSQL
163164 echo " wal_level = replica" >> " $PGDATA /postgresql.conf"
164165 fi
165166 if ! grep -q " archive_command" " $PGDATA /postgresql.conf" ; then
166- echo " archive_command = 'pgbackrest --stanza= ${PGBACKREST_STANZA :- main} archive-push %p '" >> " $PGDATA /postgresql.conf"
167+ echo " archive_command = '/bin/true '" >> " $PGDATA /postgresql.conf"
167168 fi
168169
169170 # Start PostgreSQL again
You can’t perform that action at this time.
0 commit comments