how to run a script before running a backup?

I have a task that before launching backups of all bases, I have them now 4, in Postgre SQL. I need to run the vacuum analysis command for all databases. I can’t find an example.
I can run through Pgadmin, but that script is not suitable for your program:

  • Database: buh_18, buh_test
    VACUUM ANALYSIS;

Hello,

Have you tried to resolve the issue by adding the custom script before the backups?

Thank you!