How can I migrate from Discourse Hosted to self-hosting

This is supported and should work fine.

Myself I’m not sure how the backup interacts with the defined functions… possibly it assumes they already exist in the discourse_functions schema.

Do you have this plugin (discourse-post-voting) installed? Try installing it prior to doing the restore.