There is an open source iOS app called Overland[0] that can continuously track your location history in the background and upload the data to an arbitrary endpoint as GeoJSON.
The "protocol" consists of a single HTTP request and response, so you can easily write your own server software to store the data however you want, which is what I did.
If you don't want to write your own backend, you can also just use the server software[1] the author of the app uses, which is also open source.
[0]: https://github.com/aaronpk/Overland-iOS [1]: https://github.com/aaronpk/Compass