Error when migrating to an external postgres instance

There is a remote chance that somehow the restore script does not respect the ENV variables (but everything else does?). The ways to check that are to look at the code and to try do do a restore from the UX. If you can restore from the UX then I think you could move this to Contribute > Bug.