Why provide database name when starting postgresql base backup According to the postgresql 8 manual, before starting a base backup (i.e. copying the files out of the data directory), you need to issue a command like this:

psql -d DATABASENAME -c "SELECT pg_start_backup('label');


But, since the postgresql files in the data directory contain ALL databases held by postgresql, what is the point of specifying DATABASENAME?  (eg: mydb).  Is it equally effecting to just use template0 as the databasename?
Because you must connect to a specific DB in all cases. In psql if you don't specify a database it tries to connect, at least in *nix (any Unix like OS), to a database with the same name as the user in the operating system. Not sure Windows, but I would think it probably behaves the same. 

The authentication mechanism doesn't know, or care, what operation you are about to do. It just needs to verify:


Does the user exist?
Did we get proper password for the user (unless you are setup with trust connections)?
Is the user trying to connect to a database that exists and it has rights to connect?