I know there are two ways of making a copy of a database.
One is to export the database as a giant SQL file, then load it as a separate database:
pg_dump <database> | psql <new database>
Another way is to pass the database name as a template to a database creation argument:
createdb -T <database> <new database>
What is the difference between these two methods, if any?
Are there any benefits of using one over another, such as performance?
According to the current docs
Apart from that mild warning, which goes back to at least version 8.2, you can make certain kinds of changes by using createdb–things like changing collation, encoding, etc. (Within limits.)
Personally, I’d have a hard time justifying the use of createdb, which takes a full database lock, to copy a production database.
I think the other main difference is that “dump and load” is a fully supported way of copying a database. Also, you can carry a copy of the dump to an isolated development computer for testing if you need to. (The createdb utility has to have access to both the source and the target at the same time.) But I have not used createdb to make copies, so I could be wrong.