script to run after restoring a virtual server

Is there a way to run a script after restoring a virtual server?

Status: 
Active

Comments

No, there's no feature that allows you to automatically run a script when restoring a Virtual Server.

The only way to accomplish that is if you were restoring the Virtual Server from the command line, using the command line tools. With that, you could could call a script.

For example, you could create a script that includes these two lines:

virtualmin restore-domain --source /path/to/backup_file.tar.gz
/path/to/other/script/here

Actually, the pre and post domain modification scripts get run for a restore as well.

You can go to System Settings -> Virtualmin Configuration -> Actions upon server and user creation and set the "Command to run after making changes to a server" to something like /etc/post-change.sh .

Then create the /etc/post-change.sh script containing code like :

#!/bin/sh
if [ "$VIRTUALSERVER_ACTION" = "RESTORE_DOMAIN" ]; then
  # your script here
fi

You can use the variable $VIRTUALSERVER_DOM to get the name of the domain that was restored, and other variables starting with VIRTUALSERVER_ for other details.