backup.py should be created within the Nextcloud integration folder and populated with the relevant code. I’m not 100% certain on how to request a user’s files & folders from Nextcloud’s API or WebDAV protocol programmatically, so I might have to sit this one out. I’m not a developer, just someone that’s used Python in very small areas to repeat manual efforts.
Of note: The Nextcloud integration currently cites requiring an admin user as it exposes system information as part of the integration. This unfortunately means that the user’s files in which you’re wanting to store your Home Assistant backups at must be configured as an admin user. This doesn’t follow the principle of least-privilege in my eyes, as a standard user for user data (i.e. file storage) should be separate from an admin user that administers the server. If this were to be developed, there may be some reconfiguration necessary to permit non-administrator users to authenticate to this integration and expose the non-administrator’s file storage to Home Assistant as a remote target for Home Assistant’s backup storage location.
I would not oppose learning a bit about integration and Home Assistant development, so if anyone is willing to implement this and be a bit verbose with explaining the moving pieces, that would be resourceful if nothing else.
Lastly, this user is listed as the contributor to the Nextcloud integration on the integration page. This person could likely be useful for implementing this feature.
The more I think about this, the more I wonder if the integrations should be reorganized? Existing Nextcloud integration renamed to Nextcloud Administration or something similar, and a new integration created for tasks with standard users, like backups, file storage, future expansion? Or can the existing integration utilize two authenticated users? This is where my lack of dev knowledge shows.
This should probably be implemented as a generic WebDAV backup agent. WebDAV is a standardized protocol and supported by many different servers including Nextcloud, Owncloud or plain Apache servers using mod_dav.
Just FYI for others here: I have a directory on my Nextcloud storage used for backups for various systems. I configured an NFS share for this directory restricted to Home Assistant and mounted this directory locally in Home Assistant.
Settings > System > Storage > Add Network Storage
When you select “Backup” as the usage intent, this exposes the directory as a storage location for the automated backups.