HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Check if database backup using pg_dump is in progress

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
pg_dumpdatabaseprogressusingcheckbackup

Problem

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.

Solution

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.

Context

StackExchange Database Administrators Q#173660, answer score: 4

Revisions (0)

No revisions yet.