When upgrading from a previous PostgreSQL version, there are different approaches that you can follow depending on the specific context, the amount of data you need to migrate, and the version you are coming from.
One approach that always works is to dump and restore the databases: you execute pg_dumpall against your previous cluster and pg_restore against the PostgreSQL 13 one. The main advantages of this approach are that it is simple and works with any version of PostgreSQL you are upgrading from and to. The main drawbacks are that it requires an off-line migration, meaning you are going to have a period of time where the two databases are not usable; plus, it can require a lot of time and space depending on how much data you need to migrate.
Another approach is to use pg_upgrade, a tool designed to transfer and migrate data from one cluster to another one side by side. The idea is that pg_upgrade will have access to both the clusters at the same time and...