Execute a Webmin feature from commandline (execute cluster copy)

In cluster copy you can schedule a copy files to another webmin server task.
There also is a button that says “execute”… which is nice. Manually…
Is there also a way to “execute” this from the commandline?

I cannot find any in API documentation…

There is no specific coverage in the webmin CLI for the cluster modules, but there is a copy.pl in the module directory that gets used in the cronjobs that you could call directly. It’s not very well documented (or at all), but I think you just need the copy job identifier or maybe the name of it (the get_copy function might be looking up the ID, I’m not familiar with this module).

Turning that into a friendly/documented webmin CLI command would be pretty easy, if you know any Perl. We welcome patches! :wink:

Oh, wait, I see this doesn’t have the necessary preamble to be run directly. I’m not sure how this gets setup to run…but it won’t run standalone. Sorry. It’ll need to be wrapped up into a webmin CLI command (which handles loading the Webmin core functions and setting up the environment) or have the necessary setup handled in the script itself.

Oh, and to point you in the right direction on how to make it a webmin CLI command, this command has an example of calling out to module functions (e.g. the call to acl::modify_user). You’d do the same for that run_cluster_job function just like copy.pl does…a Webmin CLI command would look almost identical, though slightly simpler/shorter, to that copy.pl script, in fact, since the webmin command runner does the boilerplate setup.

@Joe many thanks for your help. It actually seems a lot easier that I thought.
Hovering the button my browser revealed the url like:

https://webmin:10000/cluster-copy/exec.cgi?id=whatevertheid. That did not work so I looked further to anything that did the same but them from the command line.

I then discovered that when creating a cluster copy there is a cron job created also… this reveals a command like:

/etc/webmin/cluster-copy/copy.pl whatevertheid

The simple “copy.pl” in your last comment made me recognize this in the cron jobs list.

That is the one I actually needed to have in my script.

There is two parts in the cluster copy so it seems… the task part and the schedule part… the schedula part is there to create a cron job, the task part is what the cron job in return executes…

Thanks again!

1 Like

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.