docker compose exec db pg_dump -d akkoma --format=custom -f ./backup/$BACKUP_FILE
If I remember correctly, you had some problems with long restore times for the Akkoma DB when you were moving away from Contabo. This line is the source of the problem. The custom format has issues with some indexes and by default does not disable triggers when restoring, which makes PostgreSQL do a lot of unneeded work. Disabling triggers might work with the custom format, but I never tested it properly.
This is what currently use on PostgreSQL 12:
=== schema === sudo -Hu postgres pg_dump -s pleroma -S postgres -v -f /mnt/backup/pleroma-schema.psql === data === pg_dump -a pleroma --disable-triggers -S postgres -v -f - | nice bzip2 -z9 - >/mnt/backup/pleroma-data.psql.bz2 (must be ran as the postgres user, due to write permission for backup directory)Restoration is then done with psql instead of pg_restore.