Updated: if dbname is not specified, use archive.realname

... (if the stdout is a terminal).