Run custom clean up script before creating system image

Before creating a system image Cloudmin currently tries to clean up number of settings, however leaving some of them behind, which I reported here before, for example: https://virtualmin.com/node/33249

But then I am coming to conclusion that it's not possible to report all the custom places (directories) and files. For example, users could configure their backups to store files in /backup or /backups or anywhere else in the system. In our case, we have number of Varnish related setting files, which contain some data specific to the current system like, for example, IP address associated with eth0. And when we use Cloudmin to create an image from this kind of systems all the old data are preserved and we have to clean up manually. Or we need to clean up manually the existing system first and then to create a new image from it.

But the ideal and ultimate solution for all kind of Cloudmin users would be to add a new field for indicating a path to custom clean up script on Create System Image field (/server-manager/image_form.cgi). Then Cloudmin system admins could write a small custom cleanup script, which would be triggered by Cloudmin Create System Image script.

Thanks for consideration!

Status: 
Active

Comments

So Cloudmin does support having a script run before or after some operation is performed on VM, such as creation or deletion. However, at the moment this is not done when an image is created - which is a pity, as this would be the perfect place to perform any custom cleanup.

But in the next release, this script will be called before imaging as well. You can set this script at Cloudmin Settings -> Cloudmin Configuration -> Post-modification scripts. The script to do something before imaging could be like :

#!/bin/sh
if [ "$SERVERMANAGER_ACTION" = "IMAGE" ]; then
  cloudmin run-command --host $SERVERMANAGER_HOST "command to do the cleanup"
fi

Automatically closed -- issue fixed for 2 weeks with no activity.

Hi Jamie,

Based on your own words:

However, at the moment this is not done when an image is created - which is a pity, as this would be the perfect place to perform any custom cleanup.

can I turn this to a feature request to add additional field for indicating cleanup script/command on "Create System Image" window?

If you have a one-off script to run before image creation, you could just first execute it on the VM at System Operations -> Run Commands.

I know that, however I am trying to make the whole process more perfect. As yourself accepted the "Create System Image" window would be ideal place to fire up a cleanup script. Nevermind if this is a problematic feature request, however if it is not then why not to strive for better and more intuitive Cloudmin interface?!

The reason I'm reluctant to add this is that it's an extra field that most users won't want to do this, so it complicates the UI by adding an input that is rarely used.