Re: Initiate backup from routine?

From: Pyrote <pyromania(at)guungle(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Initiate backup from routine?
Date: 2024-01-17 16:15:41
Message-ID: cc0488b7ba69bcebd75391cb1615c11b@guungle.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, January 17, 2024, Troels Arvin <troels(at)arvin(dot)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.

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2024-01-17 16:24:59 Re: Initiate backup from routine?
Previous Message Ron Johnson 2024-01-17 16:15:15 Re: pg_basebackup Restore problem