This charm has two closely related concepts: "master" and "primary".
The master is elected using Juju leadership, though may still be in the
process of being promoted at the PostgreSQL level; the primary flag
indicates that the unit is not configured to be a replica.
In manual replication mode, no unit is the master, but there may be
units that are primaries. The documentation for the
`postgresql.replication.is_primary` reactive flag says "The unit is
writable. It is either the master or manual replication mode is in
effect."
We observed that in manual replication mode the WAL-E backups are
currently useless, because they have WAL but no basebackups that the WAL
might be applied to. It seems to make most sense to run basebackups
based on `is_primary` rather than `is_master`; this should leave
behaviour unchanged in the default managed replication mode.
pgbackup.py: Avoid leaving partial backups if pg_dump is interrupted
It's sometimes necessary to interrupt a daily pg_dump in order to
complete other database maintenance tasks. However, doing so results in
a partial backup file, which can result in problems if that file is
automatically restored to another system (for example, Launchpad's
staging instance works this way).
To avoid this problem, write dumps to a file whose name starts with
"partial-" (chosen to minimize the chances of scripts confusing such
files with complete backups, since the file names start with the
database name and restore scripts typically specify that), and only
rename them into place once the dump completes successfully.