I am exposing a REST API to backup a Postgres DB. I have few questions related to that. I have seen most of these questions floating around google but could not find any suitable answer

  1. Is there any way to know the status of the pg_dump? I can redirected the verbose log to the user but somehow I am not convinced with that.
  2. Is there any way to know that a "pg_dump" session is in progress so that I can prevent the user from re-triggering?

1 Answer 1


You could check if there is running pg_dump process by looking at the pg_stat_activity and also the state of the process:

FROM pg_stat_activity 
    application_name = 'pg_dump';

It would be better if you could also lock some file with your script when you are starting pg_dump and check the lock status of that file when starting new pg_dump to avoid re-triggering.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.