> Anyone have any suggestions on novel phrases to offer in my incantations for
> getting this script to do everything I need?
You need to add "-l $LOGFILE" where log is wherever you want to write
the stderr+stdout from the postmaster to. Then it will return once
starting the server.
> Also, is there any way, in the case of shutting down the
> production instance for the second pass, to have the shutdown command wait
> indefinitely? "-m smart" will give up after waiting so long, and I'd like
> neither to interrupt any running jobs, nor end up not taking a backup in the
> event a running job outlasts pg_ctl's timeout.
>
>
Not that I know of, but you can poll the server status using the same
pg_ctl command constructs as you're using already but with "status"
instead of "stop" or "start". pg_ctl (and hence ssh) will return 0 if
the server is running and 1 if the server is no running.
So you could try something like
while ssh $REMOTE pg_ctl -D $CLUSTER status
do
echo "Remote server still running - continuing to wait ..."
sleep 10
done
Hope this helps,
Robin