@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.
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.