Application hooks allow you to ensure that stateful applications like databases are in the proper state to be backed up by executing pre-backup and post-backup commands in specified containers on your cluster. You can also define post-restore commands for the flip side of the process. Once defined, App Hooks can be referenced from backup or restore definitions.
The App Hooks page contains two tabs. The My Hooks tab lists application hooks that you have defined. The Templates tab list pre-defined application hooks for common applications. You can directly use these pre-defined templates in your backup and restore jobs by selecting Enable App Hooks and then toggling on the App Hooks from templates switch and selecting them in the backup and restore definition wizards. But keep in mind that they frequently require some modification to work in specific environments.
You can customize a template by selecting the Clone option. After editing the template as desired and giving it a new name, clicking Save will save it to your My Hooks list.
Add a new App Hook as follows:
From the menu bar, open Configuration > App Hooks
Click Add App Hook + to open the Add App Hook pane.
Enter the following fields:
Enter a name for the App Hook.
Select one of the followings:
Pre-backup – Commands to be executed before a backup job is run.
Post-backup - Commands to be executed after a backup job is run.
Post-restore - Commands to be executed after a restore job is run.
Common – Can be used for two or more of Pre-backup, Post-backup, or Post-restore. Will be displayed under all categories.
- App Selector
Labels to be used to identify the pod(s) where the command(s) will be executed. If multiple labels are specified, they all must match the pod’s labels. The command(s) will be executed on all matching pods.
If the container name is not supplied, the first container in the pod will be used.
Command(s) to be run on the application container. Note that by default the command is not executed in a shell. If you require shell features for your command(s), such as variable substitution, you should start a shell and pass it your command using syntax such as
/bin/sh -c “my_command”.
You can add multiple containers and commands to an app by clicking the plus (+) icon, and you can add multiple apps by clicking + Add app. Click Save to create the App Hook.
After creating an App Hook, you will be able to select it when defining a cluster backup or restore job by enabling the Enable App Hooks option.
For more information about defining a cluster backup, follow the instructions in Creating a backup job for cluster.
To edit an App Hook in the list, click Edit for the item. To delete the App Hook, click Remove.