Hi, Unfortunately I did not have any success in loading the page.
I have encountered some issues and after checking the logs and fixing the issues (mostly related to access rights) the result is a blank page…
Then I’ve tried to run the modified perl scripts by hand in the system, and I have hit a wall.
I did not find the right location for BackupConfig.pm to be overwritten.
So i think that the NS server is still using the default script because for example backup-config-execute give me an error that it can’t use Bare words on line xxx That line has the new define for NethServer::BackupConfig::DESTINATION_DIR …
So in this moment I’m a little lost because i do not know enough regarding the NS sub-system. I’d like to be able to debug a little more about why the PHP part is not showing anything when i access the backup config section.
And how to better debug the perl scripts.
@davidep I think that we can remove the bootstrap and bootstrap-table. also the glyph’s
But this will mean that I need to make the ajax functions for download / delete / restore buttons and also for the displaying the content or refreshing of the table contents after actions.
I’ve worked on the backup Config module and until now the following are possible:
each archive has date in filename
can create more than 1 backup file
Backup script executes only if there is no backup or if the last backup done is different than the configuration (same as original but with multiple bkp files)
the backup can be triggered from the webinterface button (same as original but with multiple bkp files)
added table of current backups to the webgui (see screenshot)
TODO:
To add ajax functionality to the Download / Delete / Restore buttons.
Curently I’m having some issues with the path reference to the ajax library.
It is not getting the path to the “bkp_jlib_ajax.php” file that i have placed in the “usr/share/nethesis/NethServer/Template/BackupConfig”
Instead it is still asking to get the file from: /en-US/BackupConfig/Backup/bkp_jlib_ajax.php
the getModuleUrl() returns : /en-US/BackupConfig/Backup, But this is not usable for the script.
The ajax functionality is needed so when you click on the button, the action (delete or download or restore) is executed without re-loading the page.
The ajax library contains php functions that are executed on demand via javascript for those actions and nothing more.
The code you are using in NS is very object oriented, I have created the scripts procedural. It is too complex, and for me to try and understand how the framework works is impossible since it is not documented. I’ve tried to make some sense on the code but it is to spread between so many files.
I’ve resolved the reference call for the ajax lib by puting the file in the root of the netserver-manager.
I know that it is not the ideeal implementation but as I sayed, I have to learn the whole framework and funtctions of curent NS to make a module that is object oriented and more compatible.
Now the only issues that I’m facing is that I could not make the calls to system functions work for example to remove the specified backup file via exec(); and still to work on the restore call.
Having an effective and coherent UI style and behaviour is one of the framework goals and NethServer requirement …I know Nethgui is a Bad Guy and we lack documentation about it
Can somebody explain and share snippets regarding the usage of the NS database?
I need to see the exact way in witch a value is stored in a key and then read / write / edited / deleted.
Can anyone offere some insight on why this does return always int (1) as error ?
it drives me nuts, I’ve tried exec() passtrouh() system() and the same result… And error 1 is generic miscellaneous error
function delete_backup($file_name) {
$out;
$err;
if (isset($file_name) and !empty($file_name) and (get_file_extension($file_name) == "xz"))
{
$command='/usr/bin/sudo "rm -f /var/lib/nethserver/backup/'.$file_name.'"';
$result=exec($command, $out, $err);
if ($result) {
return ("Deleted backup ". $file_name);
} else {
return "Error removing: ". $file_name." Output: ".var_dump($out)." Error: ".var_dump($err);
};
} else {
return "Error, file is not valid for removal";
};
};
Hi Davide,
In the log i get Permission Denied. … it seems that it is not possible to do anything on the files… not via php or via perl script.
I’ve tried also with sudo but the same result.
I think that www-data should be added to the group that has access on that folder or folders.
You are referring to add something like this to sudoers ?
user ALL=(ALL) NOPASSWD: /bin/rm /var/lib/nethserver/backup/*.xz
Ok so I’m thinking that it is better that I’ll use a perl script to remove the specified backup file (and resultant files md5).
Also this will be needed for the rotation of logs when i will implement one
So it will be better to add backup-config-remove to sudo allowed.
PS: why the restore-config did not work also? It was supposed to already be allowed in sudo, no ?
The RC1 release of the BackupConfig module is ready.
I’ve put the update in git and whoever want to test it can download the files and overwrite them.
With this update a new file has been added: delete-config that needs to be placed in /sbin/e-smith/
ATTENTION You will need to add the script /sbin/e-smith/delete-config to the sudoers, !!!