ONTAP Discussions

Configuration backup upload to a https destination

Matthias_Buggle
3,847 Views

Hello,

I'am searching for a working solution to upload the configuration files from the Netapp to a https destination. I have tested with webdav on IIS and apache 2.4 on Windows. On IIS, I get a 405 error, when I try to upload a file, because the POST method is not allowed. On Apache 2.4 I have also created a webdav server with ssl enabled. When I mount the webdav ressource as a network drive in Windows, everything works fine, I can upload and download files without a problem. If I try to upload a configuration file with system configuration upload on the Netapp then I get the error 404 - file not found.  In the case, a file with the same name is already there, the Netapp says that the file was uploaded. But the file was not written.

The same webserver configuration with http works fine.

In the log-files I can see, that on the Netapp the POST method was used. The upload over a mounted drive on Windows uses the PUT Method.

 

Thank you in advance, best regards Matthias

 

6 REPLIES 6

TMACMD
3,824 Views

Have you read the Docs regarding this?

Why are trying to use webdav? Pretty sure that is not supported. Just the HTTP POST command is needed.

 

The web server to which you are uploading the configuration backup file must have PUT operations enabled for HTTP and POST operations enabled for HTTPS. Some web servers might require the installation of an additional module. For more information, see your web server’s documentation. Supported URL formats vary by ONTAP release. See the command line help for your ONTAP version.

Matthias_Buggle
3,784 Views

Hallo TMACMD,

thank you for your answer.  Every example that I found on the Internet on the subject was a solution using Webdav and http, unfortunately none with https. Is there a sample configuration with Apache and POST enabled that I can use as a template to configure a web server ?

 

Thank you.

 

Matthias_Buggle
3,678 Views

In the meantime I was able to find a solution to this problem using PHP.

I'd like to document this in case anyone else is struggling with this problem.

This description only documents the solution for performing a configuration upload , ssl and security settings are not part of the description.

The upload to a https destination uses the POST method.


I used Apache 2.4 ( from https://www.apachehaus.com ) on Windows and PHP for Apache version 8.1.9 (from www.php.net).

 

After installing Apache and unpacking the PHP package rename the file php.production to php.ini.

 

- Modify php.ini and set:

memory_limit = 250M
sys_temp_dir = < your temp directory >
file_uploads = on
upload_max_filesize = 100M

 

- To activate PHP modify the Apache httpd.conf file:

 

PHPIniDir "c:/php"
LoadModule php_module "c:/php/php8apache2_4.dll"
AddHandler application/x-httpd-php .php

 

- In the Apache htdocs directory create a directory backup

 

- In the Apache htdocs directory create a file backup.php:

 

<html>
<body>
<?php

$pathinfo = $_SERVER['PATH_INFO'];
$destination = 'backup'.$pathinfo;

 

file_put_contents($destination, file_get_contents('php://input'));

 

file_put_contents('php://stderr',print_r($destination,TRUE));

file_put_contents('php://stderr',print_r(PHP_EOL,TRUE));

?>
</body>
</html>

 

- Now you can backup the cluster configuration on the NAS filer:

set adv
system configuration backup show
system configuration backup upload -node <NAS-node> -backup <configuration.7z> -destination https://web-server/backup.php

 

Duke1290
2,557 Views

Hi Matthias,
We tried to replicate your config on  the upload succeds but the file is not actually stored anywhere on the system... i.e the file disappears after upload..
My guess is that this part does not work as expected:

<?php

$pathinfo = $_SERVER['PATH_INFO'];
$destination = 'backup'.$pathinfo;

Any ideas for alternate syntax to get the pathinfo correct?
/B





darkavich
1,663 Views

Look in your apache error_log file. 
I had to change the line in mine to:

 

"$destination = '/var/www/html/netapp/backups'.$pathinfo;"

 

The web server plugin for PHP doesn't understand the relative path.

Make sure this directory has the permissions set for the user that the httpd service runs under and is writable. 

 

I was able to get this to work after doing this.

darkavich
397 Views

I ran into a problem with this, maybe after an upgrade, not sure. I am getting the following errors:

PHP Notice:  Unknown: file created in the system's temporary directory in Unknown on line 0

[php:warn] [pid 5647] [client ...] PHP Warning:  Unknown: Input variables exceeded 5000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0

 [php:warn] [pid 5647] [client ...] PHP Warning:  file_put_contents(/var/www/html/netapp/backups/weekly.2024-09-29.00_15_00.7z): Failed to open stream: Permission denied in /var/www/html/netapp/backup.php on line 9


There is no way this can be exceeding 5000 cookies. I think something else is going on. Anyone have any ideas?

Public