I've been working on this issue lately. There is quite a bit more to a database than the tables (e.g., functions), and I'm not sure how you would go about getting a backup of the entire database through SQL. I've been working on a Java class to do the dump and restore. It doesn't look terribly hard.
However, having said that, I wonder if someone could answer something. How do pg_dump and pg_restore use stdout and stderr? I saw a very old post that indicated -v caused all output to go to stderr. I couldn't find anything recent and nothing in the manual.
Thanks!
Michael Schmidt