Question about creating a standby from a stanza

Hello

pglift version

pglift version 0.31.0

Summary

Getting error from instance create --standby-for="host=pg1.local port=5432 user=replication" [...].

Steps to reproduce

When creating a standby from a primary I get this error:

pglift instance create --replrole-password="replication" --standby-password="replication" --standby-for="host=pg1.local port=5432 user=replication" --pgbackrest-stanza="essential" main
INFO     initializing PostgreSQL instance                             
INFO     configuring PostgreSQL authentication                        
INFO     configuring PostgreSQL instance                              
INFO     starting PostgreSQL cluster 14-main                          
INFO     setting up pgBackRest                                        
INFO     creating pgBackRest stanza essential                         
WARNING  Command '['/usr/bin/pgbackrest',                             
         '--config-path=/var/lib/pgsql/.local/share/pglift/etc/pgbackr
         est', '--log-level-stderr=info', '--stanza=essential',       
         'check']' returned non-zero exit status 27.                  
WARNING  reverting: creating pgBackRest stanza essential              
INFO     deleting pgBackRest stanza essential                         
WARNING  reverting: setting up pgBackRest                             
INFO     deconfiguring pgBackRest                                     
WARNING  reverting: initializing PostgreSQL instance                  
INFO     deleting PostgreSQL instance                                 
Error: Command '['/usr/bin/pgbackrest', '--config-path=/var/lib/pgsql/.local/share/pglift/etc/pgbackrest', '--log-level-stderr=info', '--stanza=essential', 'check']' returned non-zero exit status 27.
INFO: check command begin 2.45: --config-path=/var/lib/pgsql/.local/share/pglift/etc/pgbackrest --exec-id=16495-70f75156 --log-level-stderr=info --log-path=/var/lib/pgsql/.local/share/pglift/log/pgbackrest --pg1-path=/var/lib/pgsql/.local/share/pglift/srv/pgsql/14/main/data --pg1-port=5432 --pg1-user=postgres --repo1-path=/var/lib/pgsql/backups --stanza=essential
ERROR: [027]: primary database not found
       HINT: check indexed pg-path/pg-host configurations
INFO: check command end: aborted with exception [027]

Since it is a standby creating the stanza should be avoided.

And in pgBackrest configuration file pg1-host is not present, making pgbackrest trying to restore from local backup:

[postgres@pg1 pgbackrest]$ cat pgbackrest.conf 
[global]
lock-path = /run/user/26/pglift/pgbackrest/lock
log-path = /var/lib/pgsql/.local/share/pglift/log/pgbackrest
spool-path = /var/lib/pgsql/.local/share/pglift/srv/pgbackrest/spool
repo1-path = /var/lib/pgsql/backups
repo1-retention-archive = 2
repo1-retention-diff = 3
repo1-retention-full = 2
[postgres@pg1 pgbackrest]$ cat conf.d/essential.conf 
[essential]
pg1-path = /var/lib/pgsql/.local/share/pglift/srv/pgsql/14/main/data
pg1-port = 5432
pg1-user = postgres

Tried using --pgbackrest-restore-stanza but got this error:

[postgres@pg2 ~]$ pglift instance create --replrole-password="replication" --standby-password="replication" --standby-for="host=pg1.local port=5432 user=replication" --pgbackrest-restore-stanza="essential" --pgbackrest-stanza=essential main
INFO     initializing PostgreSQL instance                             
INFO     creating instance from pgbackrest backup                     
WARNING  Command '['/usr/bin/pgbackrest', '--log-level-file=off',     
         '--log-level-stderr=info', '--config-path',                  
         '/var/lib/pgsql/.local/share/pglift/etc/pgbackrest',         
         '--stanza', 'essential', '--pg1-path',                       
         '/var/lib/pgsql/.local/share/pglift/srv/pgsql/14/main/data', 
         '--type=standby', '--recovery-option',                       
         'primary_conninfo=user=replication host=pg1.local port=5432  
         password=replication', 'restore']' returned non-zero exit    
         status 75.                                                   
WARNING  reverting: initializing PostgreSQL instance                  
INFO     deleting PostgreSQL instance                                 
Error: Command '['/usr/bin/pgbackrest', '--log-level-file=off', '--log-level-stderr=info', '--config-path', '/var/lib/pgsql/.local/share/pglift/etc/pgbackrest', '--stanza', 'essential', '--pg1-path', '/var/lib/pgsql/.local/share/pglift/srv/pgsql/14/main/data', '--type=standby', '--recovery-option', 'primary_conninfo=user=replication host=pg1.local port=5432 password=replication', 'restore']' returned non-zero exit status 75.
INFO: restore command begin 2.45: --config-path=/var/lib/pgsql/.local/share/pglift/etc/pgbackrest --exec-id=16634-191dbc5f --lock-path=/run/user/26/pglift/pgbackrest/lock --log-level-file=off --log-level-stderr=info --log-path=/var/lib/pgsql/.local/share/pglift/log/pgbackrest --pg1-path=/var/lib/pgsql/.local/share/pglift/srv/pgsql/14/main/data --recovery-option="primary_conninfo=user=replication host=pg1.local port=5432 password=replication" --repo1-path=/var/lib/pgsql/backups --spool-path=/var/lib/pgsql/.local/share/pglift/srv/pgbackrest/spool --stanza=essential --type=standby
WARN: repo1: [FileMissingError] unable to load info file '/var/lib/pgsql/backups/backup/essential/backup.info' or '/var/lib/pgsql/backups/backup/essential/backup.info.copy':
      FileMissingError: unable to open missing file '/var/lib/pgsql/backups/backup/essential/backup.info' for read
      FileMissingError: unable to open missing file '/var/lib/pgsql/backups/backup/essential/backup.info.copy' for read
      HINT: backup.info cannot be opened and is required to perform a backup.
      HINT: has a stanza-create been performed?
ERROR: [075]: no backup set found to restore
INFO: restore command end: aborted with exception [075]

How can I make pglift to set pg1-host ?

Site settings

lock_file: /run/user/26/pglift/.pglift.lock
logpath: /var/lib/pgsql/.local/share/pglift/log
logrotate: null
patroni: null
pgbackrest:
  configpath: /var/lib/pgsql/.local/share/pglift/etc/pgbackrest
  execpath: /usr/bin/pgbackrest
  lockpath: /run/user/26/pglift/pgbackrest/lock
  logpath: /var/lib/pgsql/.local/share/pglift/log/pgbackrest
  repository:
    path: /var/lib/pgsql/backups
    retention:
      archive: 2
      diff: 3
      full: 2
  spoolpath: /var/lib/pgsql/.local/share/pglift/srv/pgbackrest/spool
postgresql:
  auth:
    host: scram-sha-256
    local: peer
    passfile: /var/lib/pgsql/.pgpass
    password_command: []
  backuprole:
    name: postgres
    pgpass: false
  bindir: /usr/pgsql-{version}/bin
  datadir: /var/lib/pgsql/.local/share/pglift/srv/pgsql/{version}/{nam
  default_version: '14'
  dump_commands:
  - - '{bindir}/pg_dump'
    - -Fc
    - -f
    - '{path}/{dbname}_{date}.dump'
    - -d
    - '{conninfo}'
  dumps_directory: /var/lib/pgsql/.local/share/pglift/srv/dumps/{versi
  initdb:
    data_checksums: true
    encoding: UTF8
    locale: C
  replrole: replication
  restore_commands:
  - - '{bindir}/pg_restore'
    - -d
    - '{conninfo}'
    - '{createoption}'
    - '{path}/{dbname}_{date}.dump'
  socket_directory: /var/run/postgresql
  surole:
    name: postgres
    pgpass: false
  versions:
  - bindir: /usr/pgsql-14/bin
    version: '14'
  waldir: /var/lib/pgsql/.local/share/pglift/srv/pgsql/{version}/{name
powa: null
prefix: /var/lib/pgsql/.local/share/pglift
prometheus: null
run_prefix: /run/user/26/pglift
scheduler: systemd
service_manager: systemd
systemd:
  sudo: false
  unit_path: /var/lib/pgsql/.local/share/systemd/user
  user: true
sysuser:
- postgres
- postgres
temboard: null

Robin,

Edited by Robin Portigliatti