We have documented how to create a full backup of Discourse, but this guide is specific for the Bitnami Discourse Stack, because it is self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory.
About a generic way, you can use the admin page. You can visit https://YOUR_OLD_SITE/admin/backups, on this page you can create a backup and download it. After that, you can go to https://YOUR_NEW_SITE/admin/backups and upload the previous backup to the new machine.
Carlos R. Hernández