Upgrade script fails on postgres backup

I’m trying to upgrade from 6.03 to 6.1 & this is my error…

Backing up PostgreSQL database in /mnt/2/var/www/videos.domain.org/peertube/backup/sql-peertube_prod-20240524-0813.bak
pg_dump: error: query failed: ERROR: permission denied for schema pgagent
pg_dump: detail: Query was: COPY pgagent.pga_jobagent (jagpid, jaglogintime, jagstation) TO stdout;

I’m not asked for a password. I had to edit my script.sh to include the proper directory.