PostgreSQL duplicate a user with same permission

That is not easy to do, because permissions are not stored on the user, but on the object: every table, view, function etc. knows which user has which permissions on it. So to copy the permissions of a user, you'd have to copy all the object definitions.

So that is what you can do: run pg_dump -s dbname to dump all metadata of a database and restore them to the new database. If you want to change the user name in the new database, just rename the role.