Hi Developers,
I am submitting a patch that introduces a new function, XLogBackupStatus(XLogRecPtr *lastBackupStart), to the core PostgreSQL codebase. This function allows extensions to reliably determine if a base backup is currently in progress (across all sessions), and to retrieve the LSN of the last backup start.
Why is this patch needed?
Currently, there is no public API in PostgreSQL that allows extensions to:
- Reliably detect if a base backup (e.g., via pg_basebackup or SQL backup functions) is running globally (not just in the current session).
- Retrieve the LSN at which the last backup started.
- The existing get_backup_status() function only reports the backup state for the current session, which is insufficient for extensions that need to coordinate actions with global backup activity.
Any extension that needs to synchronize its state with PostgreSQL’s backup process can benefit from this API.
If there is an existing, supported way to achieve this functionality in an extension (without relying on private symbols or patching core), I would greatly appreciate your guidance.
If you have concerns about the patch, or suggestions for improvement, I am happy to revise and resubmit as needed.
Thank you for your time and consideration!
Thanks and Regards,
Sujan B
Member Technical Staff
ZOHO Corporation