On Wednesday, January 17, 2024, Troels Arvin <troels@arvin.dk> wrote:
> Is it possible to call pg_dump (or equivalent action) through a
> procedure/function?
You could create a new schema and table that holds a flag column or a
simple queue.
Then setup a script/app on a 5 minute cron that checks the status of the
flag or queue to see if it needs to start a backup.
The script/app could update the table to show the user that the backup
has started and when its finished.
The user account on the DB server that runs the code would have their
shell set to /bin/false so they cannot login. The DB account used by the
code would have the minimum privileges to perform the backup.
Or if it needs to be more real-time, the app could use LISTEN/NOTIFY to
trigger the backup process. Then use cron on some interval to make sure
the app is always running.
Then you just need the procedure to update the flag/queue or send a
NOTIFY message.