Since Josh Drake has failed to allow comments on his very excellent blog, especially
this post,I have to respond below.
We're going to use the Model-View-Controller pattern to do backups on any platform PostgreSQL supports.
First, let's make a file that does the Model and View parts:
cat backup.sql
WITH t AS ( -- This part is the model.
SELECT quote_ident(datname) AS d
FROM pg_database WHERE NOT datistemplate
)
SELECT
'pg_dump -U postgres -Fc --file=' || d || -- This part is the view.
to_char(now(),'_YYYYMMDD') ||
'.pgbackup' || ' '|| d
FROM t;
Next, we make a controller.
psql -Atqf backup.sql |sh
Note: if you're on Windows, you can substitute cmd.exe or command.com as appropriate for sh in the above.
Done!