Impossible to upgrade twice from old instance with pgbackrest

pglift version

0.15.0

Summary

When pgbackrest is configured in site settings, executing the instance upgrade command more than once fails.

In my case, I dropped the upgraded instance to recreate it from the old one but pgbackrest is missing something.

Steps to reproduce

$ pglift instance create old --version=15 --port=5432 --pgbackrest-stanza=myapp
[...]
$ pglift instance stop
[...]
$ pglift instance upgrade --version 16 --name upgraded --port 5433 old
[...]
$ pglift instance drop upgraded
[...]
$ pglift instance upgrade --version 16 --name upgraded --port 5433 old
Error: 1 validation error for Instance
pgbackrest
  Field required [type=missing, input_value={'name': 'upgraded', 'ver.../srv/pgsql/15/old/wal')}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing

I suspect that this is due to a lack of stanza configuration. Indeed, after the upgrade the pgbackrest configuration for the stanza has been changed to match the upgraded instance. If we drop it, the configuration is also dropped. Then the old instance doesn't have stanza configuration anymore.

By the way, the "validation error" is not very informative. It's very difficult to know which field is missing for pgbackrest in Instance manifest.

Site settings

postgresql:                           
  versions:                           
  - bindir: /usr/lib/postgresql/15/bin
    version: '15'                     
  - bindir: /usr/lib/postgresql/16/bin
    version: '16'                     
pgbackrest:                           
  execpath: /usr/bin/pgbackrest       
  repository:                         
    mode: path                        
    path: /tmp/backups