How to wait for PostgreSQL to be startable / restorable?
initdb doesn't return until it's finished, so there shouldn't be any pause needed between it and server startup.  There have been bugs in PostgreSQL where it completed without flushing everything to disk first though.  I don't know of any left right now, but the nature of bugs is that you don't always know about them.

If you use the pg_ctl command to start the database, use the "-w" parameters for that to wait until startup is finished before returning.  It doesn't do anything fancy--it just does the "is it ready yet?" loop for you.

Note that if you get a server crash with a lot of data that needs to be replayed before the server can start, the timeout set by "-t" on the pg_ctl waiting might be too low.

There is no reason to VACUUM the source databases before doing a pg_dump of them.  While it might speed the dump up a bit, the vacuum itself will take longer than that improvement.