Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup nextcloud v2 #2289

Merged
merged 2 commits into from
Apr 2, 2018
Merged

backup nextcloud v2 #2289

merged 2 commits into from
Apr 2, 2018

Conversation

fabianfrz
Copy link
Member

@AdSchellevis here is an updated version

Copy link
Member

@fichtner fichtner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, I'll work on integrating SCP like this as well now

@fabianfrz
Copy link
Member Author

@fichtner SCP is slightly different because it may be harder to do a directory listing. One of the big advantages is, that it can be safe to put the modules into plugins since it is a single file.

@AdSchellevis
Copy link
Member

@fabianfrz I'll try to review this weekend and pull it in, great work!

@fabianfrz
Copy link
Member Author

@AdSchellevis @fichtner If there are many backup implementations, it would make sense to use tabs but it's ok for now.

@fichtner
Copy link
Member

fichtner commented Mar 24, 2018 via email

@fabianfrz
Copy link
Member Author

Like Interfaces? May slow down the web interface and is not often needed. Probably better where it is now.

@fichtner
Copy link
Member

no, static and cached via its own Menu.xml

$config = $cnf->object();
foreach ($fields as &$field) {
$fieldname = $field['name'];
if (isset($config->system->remotebackup->$fieldname)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better to place the settings in it's own container (for example system->backup->nextcloud->..), even better would be to use a model class to handle validations.

$input_errors[] = gettext('The Backup Directory can only consist of alphanumeric characters.');
}
// required fields
if (isset($config['system']['remotebackup']['nextcloud_enabled']) && $config['system']['remotebackup']['nextcloud_enabled'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$config not known here, either push the validations to a model or fetch the config object like

$config = Config::getInstance()->object();
if (!isset($config->system->remotebackup)) {
$config->system->remotebackup = array();
}

}
foreach ($this->getConfigurationFields() as $field) {
$fieldname = $field['name'];
if ($field['type'] == 'file') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you're not using a model (which would need a refactoring of this section), you could ditch the file handling here, the settings don't seem to require file type inputs.

@fabianfrz
Copy link
Member Author

@AdSchellevis hope it is ok now - please note that there is some stuff inside the code, which should not be in (imho):

@AdSchellevis
Copy link
Member

@fabianfrz Thanks! there is indeed room for improvement, let me pull this in and refactor some when I have some time available.

@AdSchellevis AdSchellevis merged commit d803e53 into opnsense:master Apr 2, 2018
@fabianfrz fabianfrz deleted the nextcloud-v2 branch April 2, 2018 08:52
@AdSchellevis
Copy link
Member

@fabianfrz can you try this d465ef2 602e42f ? I don't have a nextcloud account available to test.

@fabianfrz
Copy link
Member Author

Does nothing anymore. Probably the changes in the "if" will stop it working.

@AdSchellevis
Copy link
Member

no logging, nothing?

@fabianfrz
Copy link
Member Author

nothing.

@fabianfrz
Copy link
Member Author

I can make you an account on my nextcloud instance if you like.

@AdSchellevis
Copy link
Member

sure, it's probably something small. just to be sure, you did save settings? I moved all the properties...

When I add random data, I do have entries in syslog like:

Apr  2 18:16:53 OPNsense config[81954]: Error while fetching filelist from Nextcloud
Apr  2 18:16:53 OPNsense config[81954]: {"url":"http:\/\/dsfasdfsdx\/remote.php\/dav\/files\/dsfasdfsa1\/","content_type":null,"http_code":0,"header_size":0,"request_size":0,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.534771,"namelookup_time":0,"connect_time":0,"pretransfer_time":0,"size_upload":0,"size_download":0,"speed_download":0,"speed_upload":0,"download_content_length":-1,"upload_content_length":-1,"starttransfer_time":0,"redirect_time":0,"redirect_url":"","primary_ip":"","certinfo":[],"primary_port":0,"local_ip":"","local_port":0}

@fabianfrz
Copy link
Member Author

Found out the issue: the behaviour has changed. before your refactoring the test did run even when the "enabled" flag was false. Now the check prevents the test.

When it is enabled, it is working.

@AdSchellevis
Copy link
Member

ok, nice, thanks for testing. I think it's better to skip testing when disabled.

@fabianfrz
Copy link
Member Author

so no account needed ;)

@AdSchellevis
Copy link
Member

nope, easier on my end :)

@fichtner
Copy link
Member

fichtner commented Apr 2, 2018

I get these in the background, probably during a migration run:

Apr 2 17:27:50 | config[50537]: Model OPNsense\Backup\NextcloudSettings can't be saved, skip ( Phalcon\Validation\Exception: [OPNsense\Backup\NextcloudSettings:enabled] value should be a boolean (0,1) [OPNsense\Backup\NextcloudSettings:url] An URL for the Nextcloud server must be set. [OPNsense\Backup\NextcloudSettings:user] An user for the Nextcloud server must be set. [OPNsense\Backup\NextcloudSettings:password] A password for a Nextcloud server must be set. in /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php:512 Stack trace: #0 /usr/local/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php(616): OPNsense\Base\BaseModel->serializeToConfig() #1 /usr/local/opnsense/mvc/script/run_migrations.php(56): OPNsense\Base\BaseModel->runMigrations() #2 {main} )
-- | --
Apr 2 17:27:50 | config[50537]: [OPNsense\Backup\NextcloudSettings:password] A password for a Nextcloud server must be set.
Apr 2 17:27:50 | config[50537]: [OPNsense\Backup\NextcloudSettings:user] An user for the Nextcloud server must be set.
Apr 2 17:27:50 | config[50537]: [OPNsense\Backup\NextcloudSettings:url] An URL for the Nextcloud server must be set.
Apr 2 17:27:50 | config[50537]: [OPNsense\Backup\NextcloudSettings:enabled] value should be a boolean (0,1)
``

@fabianfrz
Copy link
Member Author

the first line says it fails in runMigrations - however there is probably no data to migrate

@fabianfrz
Copy link
Member Author

@fichtner add the following defaults?
enabled: 0
url: https://nextcloud.example.com
user: opnsensebackup
password: opnsensebackup

@fichtner
Copy link
Member

fichtner commented Apr 2, 2018

I don't know, maybe we shouldn't render unused models. it seems silly to enforce this.

In any case, the error is bad and everyone will report it...

@fabianfrz
Copy link
Member Author

@fichtner maybw the migration script should check if the mount piont exist before running a migration. That would fix some other models in the plugins as well.

@AdSchellevis
Copy link
Member

@fabianfrz @fichtner I have two possible solutions here, use constraints between fields, added DependConstraint type which could help here. Let me push a simple model fix

@fichtner
Copy link
Member

fichtner commented Apr 3, 2018

yes, that looks good to me

The basic trouble is we want to render model defaults in new model versions so we can use them unconditionally, but then again sometimes that makes no sense at all because it's not used unconditionally :)

AdSchellevis added a commit that referenced this pull request Apr 3, 2018
fichtner pushed a commit that referenced this pull request Apr 3, 2018
(cherry picked from commit 6f7c10a)
(cherry picked from commit a994558)
@fichtner
Copy link
Member

fichtner commented Apr 3, 2018

works perfectly ❤️

@wols
Copy link

wols commented Jun 23, 2018

Cool new feature, thanks!

No work on my OPNsense 18.1.10-i386:

config[34300]: {"url":"https:\/\/cloud.my.domain\/remote.php\/dav\/files\/CORRECT_USERNAME\/","content_type":null,"http_code":0,"header_size":0,"request_size":0,"filetime":-1,"ssl_verify_result":19,"redirect_count":0,"total_time":0.137768,"namelookup_time":0.004656,"connect_time":0.005135,"pretransfer_time":0,"size_upload":0,"size_download":0,"speed_download":0,"speed_upload":0,"download_content_length":-1,"upload_content_length":-1,"starttransfer_time":0,"redirect_time":0,"redirect_url":"","primary_ip":"192.168.1.77","certinfo":[],"primary_port":443,"local_ip":"192.168.1.1","local_port":21665}

I use CaCert on https://cloud.my.domain - is this and ssl_verify_result:19 my problem?
See #1460 also?

@fabianfrz
Copy link
Member Author

yes. you need a trusted certificate.

@wols
Copy link

wols commented Jun 23, 2018

Ok. No way to add https://www.cacert.org/certs/root.crt and trust it?
All my other applications (apache, openldap...) use it...

@fabianfrz
Copy link
Member Author

@wols The GUI currently does not support it. It relies on the Mozilla certificate bundle. You have to add it manually and keep in mind that an update of the certificate bundle may undo your changes.

@wols
Copy link

wols commented Jun 23, 2018

Thanks a lot - I added CaCert and it works:

cat root.crt >> /usr/local/share/certs/ca-root-nss.crt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants