It is a matter of choice. What you are doing with the script is making a backup of the entire PostgreSQL data file directory. That includes all PostgreSQL system catalogs as well as user objects. A restore of your data directory would be faster than a full restore of pg_dump as indexes and constraints would not have to be recreated. However, it does not give you the option to restore one or more selected objects. pg_dump, on the other hand, gives you the flexibility of selecting what to backup and what to restore. FWIW, I much prefer pg_dump.
--
Melvin Davidson I reserve the right to fantasize. Whether or not you wish to share my fantasy is entirely up to you.