Check if database backup using pg_dump is in progress I am using PostgreSQL 9.2 and using pg_dump to create DB backup. How could I determine is db backup and restore is in progress. So I can prevent another user in initiating another.
The only thing I can think of is to check pg_stat_activity.application_name and see if any session with pg_dump (or pg_restore) is currently active. 



application_name is a value supplied by the client connecting to the database. So in theory this is not something that can be trusted completely - but I am not aware that pg_dump allows you to overwrite this. And if you don't use that information for security purposes this should be OK.