To dump a simple postgresql database, you can do something like:
pg_dump postgresql://lemmy:mypassword@example.com/lemmy -f backup.sql
This should result in a file being made named backup.sql
for your database.
As for upgrading, my small instance with a 1.5Gb database upgraded with no issues using the docker images on kubernetes.