Core: Backup to Nextcloud

Created on 17 Mar 2020  路  10Comments  路  Source: opnsense/core

Is your feature request related to a problem? Please describe.
At the moment as far as I understand it, it is not possible to backup into a subdirectory of nextcloud. (Short discussion was here https://github.com/opnsense/core/issues/2250, but not really a solution). If I add a path to the Directory Name field I get the error

The Backup Directory can only consist of alphanumeric characters.

If I use e.g. example.com/nextcloud/remote.php/dav/files/USERNAME/Backups as update URL i get the error

Saved settings, but remote backup failed.

Describe the solution you'd like
It would be nice to either be able to use one of the two methods for putting the Update into a specific folder.

Additional context
I think it would be more convenient and would also support other webdav services if a general "add webdav backup" with the link method would be available.
Based on this one can also implement a short cut for nextcloud (and other webdav servers) where one only has to enter the base url and in the Directory field one can enter the path and in the background the strings will be concatenated according to the Nextcloud requirements.

feature

All 10 comments

Your nextcloud url should be https://example.com/nextcloud and your directory Backups. Then it should work to send files into that directory.

I can send files to the root directory of my user, but not into a subfolder (e.g. Backups/opnsense).
As far as I understand the code in https://github.com/opnsense/core/blob/dc3ef63c52a24a3770509755989f5e21a884553a/src/opnsense/mvc/app/library/OPNsense/Backup/Nextcloud.php it should work, but I think the string of the Backup directory is first tested to only contain alphanumeric characters which should in my understanding be changed to alphanumeric characters and backslash.

I think the problem is here in line 51:
https://github.com/opnsense/core/blob/dc3ef63c52a24a3770509755989f5e21a884553a/src/opnsense/mvc/app/models/OPNsense/Backup/NextcloudSettings.xml#L49-L54

backslashes should be never allowed. Slashes could be theoretically in the URL but I have not implemented the nested MKCOL requests (create directory in nextcloud) to ensure that the directory exists when I try to write the file into it.

Sorry I confused the two.
Do you think that would be a big effort?
I maybe can try to change the code and make a pull request but may take a while (I don't know much about php)...

You do not only need php knowlege, also WEBDAV knowlege is required.

+1 this issue. Automatic Nextcloud backups are great, but being able to organize them into a subdir would be greatly preferred

I posted a PR which implements subdir allowance. I made a couple of tests with the default config and with subdirs and seems to work fine

This issue has been automatically timed-out (after 180 days of inactivity).

For more information about the policies for this repository,
please read https://github.com/opnsense/core/blob/master/CONTRIBUTING.md for further details.

If someone wants to step up and work on this issue,
just let us know, so we can reopen the issue and assign an owner to it.

If someone wants to step up and work on this issue, just let us know, so we can reopen the issue and assign an owner to it.

The PR is open and waiting for a review

Was this page helpful?
0 / 5 - 0 ratings