This was quiet an ordeal, but a combination of preexisting tools and a few lines of custom scripting made it possible.
I really benefitted from having a script to create whole database from scratch, heavily recommended. That part is inspired by: https://mgdm.net/weblog/postgresql-in-a-nix-shell/
What you need: postgres server, psql, pg_dump (all of those come standard with postgres installation) and pgloader. The postgresql starting script is written for nodejs but you could easily replace it...
The basic process is as follows
- load the data from sqlite to postgres as is
- fix any incompatibilities that'd break step 5
- dump the data (not the schema)
- on new database create the db from schema
- import the data from step 3
- done
To do that with scripts below (you'll need to modify at least the fix.psql) you need to run
bash restore1.sh && bash restore2.sh