Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to schedule pg_dump using pg_cron? #338

Open
ploef opened this issue Jul 12, 2024 · 2 comments
Open

Is it possible to schedule pg_dump using pg_cron? #338

ploef opened this issue Jul 12, 2024 · 2 comments

Comments

@ploef
Copy link

ploef commented Jul 12, 2024

Hi,

Would it be possible to schedule pg_dump with a pg_cron schedule? I tried something like this:

``
SELECT cron.schedule(
'one_time_pg_dump', -- job name
'*/1 * * * *',
$$pg_dump -U myUser -d my_db -f /tmp/dump_$(date +%Y%m%d%H%M%S).sql$$
);

``

But the execution returns the message:

ERROR: syntax error at or near "pg_dump"
LINE 1: pg_dump -U myUser -d my_db -f /tmp/dump_$(date +%Y%m%...
^

@marcoslot
Copy link
Collaborator

Not directly, since it cannot run shell commands. You'd need another extension that lets you run pg_dump via a SQL query.

@ploef
Copy link
Author

ploef commented Jul 12, 2024

Thanks for the quick response!
Ah that's to bad. I was using pgAgent for that but that's actually way too heavy for what I need. Do you have a suggestion for an extension that I could best use for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants