PostgreSQL 18 update for self-hosters

Where you can’t access the admin panel because your discourse has decided to lose its mind, how do you grab the db via root@ to upload to a new instance? (maybe another guide)

Or what’s the command line to execute the same thing as if doing via admin panel?