I am using an app for this. It's called WebDavNav+ and there is a free version WebDavNav for evaluation.
You can create sync configurations and switch on auto sync.
I have an Odroid HC4 with Open Media Vault and docker which is my personal NAS. It runs a WebDav container and so on a daily basis my iPhone is backing up photos to my NAS using WebDavNav+.