Presuming you are jacked into the command line on the server hosting your mongodb, it should be something like this:
mongodump --out /var/backups/mongo/$(date +%F)
I say "something like" because the simple form above would represent a poorly secured mongodb. Hence, you will most likely need a few additional flags:
mongodump -u "YourDbAdminUser" -p "SomePassPhrase" --out /var/backups/mongo/$(date +%F) --authenticationDatabase=admin
Upon successful completion that command will create a directory structure under /var/backups/mongo containing a full backup of your mongo database(s). You will then need to mongorestore this to your new server.
Mind you, the above only gets the database. You will likely also want the public file uploads and such. I suggest you review the NodeBB Upgrade Docs for further clarification.