Hooks are points during the backup process where you can execute custom scripts at the beginning, at the end and during the backup process.

All hooks are located in the ./hooks/ directory.

We have hooks “before” a step starts and “afterwards”.

List of hooks

In the IML Backup exist the following hooks

Hook where description
100-before-backup at the beginning of the backup
200-before-db-service before starting a backup of a backup type (mysql, sqlite, …)
210-before-db-dump unused
220-after-db-dump unused
230-after-db-service after finishing a database type
300-before-transfer before starting transfer of all directories
310-before-folder-transfer before starting transfer of a single directory
320-after-folder-transfer after transfer of a single directory
330-after-prune after pruning data
340-after-verify after verifying data
400-post-backup after all backup steps

At the beginning the startup hook (100-before-backup) and the post hook (400-post-backup) for triggering a message might be the most common to use.

Subdirs of a hook dir

Below all hook directories have the subdirectory “always”: ./hooks/[Name-of-hook]/always/

“before” actions

They don’t know an execution status of something. They can execute only scripts that are located in “always” subdirectory.

“after” actions

The “afterwards” added hooks know the execution status of the last action. That’s why in the hook directory we have additionally the subdirs

  • ./hooks/[Name-of-hook]/on-ok/ - the last action was 0 (zero)
  • ./hooks/[Name-of-hook]/on-error/ - if the exitcode was non-zero

After execution of the scripts of “on-ok” or “on-error” additionally the found scripts of “always” will be executed.

Tree view of hook directories

> tree -d hooks/
|-- 100-before-backup
|   `-- always
|-- 200-before-db-service
|   `-- always
|-- 210-before-db-dump
|   `-- always
|-- 220-after-db-dump
|   |-- always
|   |-- on-error
|   `-- on-ok
|-- 230-after-db-service
|   |-- always
|   |-- on-error
|   `-- on-ok
|-- 300-before-transfer
|   `-- always
|-- 310-before-folder-transfer
|   `-- always
|-- 320-after-folder-transfer
|   |-- always
|   |-- on-error
|   `-- on-ok
|-- 330-after-prune
|   |-- always
|   |-- on-error
|   `-- on-ok
|-- 340-after-verify
|   |-- always
|   |-- on-error
|   `-- on-ok
`-- 400-post-backup
    |-- always
    |-- on-error
    `-- on-ok

34 directories

What will be executed?

When processing a hook all files will be sorted in alphabetic order. Files starting with a dot will be ignored. Each found executable file will be executed.


Before the backup starts we want to update some local information that we want to put as latest information. I have a script that gets the list of installed linux packages as a textfile. If my system is damaged and I need to reinstall it this list will help me to reinstall all applications and libraries.

If my bash script that does the job is /home/axel/scripts/ … and we let it run on each start of the backup. That’s why we use the 100-before-backup hook:

Create a file named hooks/100-before-backup/always/ which has the content:

#!/usr/bin/env bash

If you have the installation in a user directory keep in mind that the backup runs as root. Set executable permissions for root. If owner and group is your user then set exection permissions for the world: 0755:

> chmod 0755 hooks/100-before-backup/always/
> ls -l hooks/100-before-backup/always
total 4
-rwxr-xr-x 1 axel axel 79 Oct  7 22:36