@kaia suggestion: use restic: https://restic.readthedocs.io/en/stable/
It can upload to b2 natively, is a single go binary, and the pg_dump command can be called directly, thus you'd end up with a single command for the backup. Encryption is also handled natively, so no additional openssl required.
I'd need to verify the exact command, don't have it out of my head.
The script itself looks good to me.