In this feature spotlight, we will showcase the custom hooks feature inside of JetBackup 5. This feature gives Server Administrators the ability to execute custom scripts before (pre), or after (post) JetBackup 5 performs a function.

For this post, we will go over how you can take advantage of our Custom Hooks feature to back up the contents of an Account’s ETC folder and include it in a scheduled backup job.

Please note that JetBackup does not officially support backing up the Account Home ETC folder. This script may not work with your specific server configuration and may require additional consideration depending on your server environment, so please proceed at your own risk.

Creating the Hook Script:

First, we will create the bash script that will run as our Pre Backup Account Hook. This Hook Script will run before the Account Backup of all Accounts included in the backup job. We use Rsync to copy the files with no symlinks to a new directory, including it in the backup.

NOTE: JetBackup 5 passes each Hook Event a unique set of ARGS for the Hook Event Script. Here, the Pre Backup Hook Event Script uses the following ARGS:

  1. $1 – Backup Job ID
  2. $2 – Account ID
  3. $3 – Account User Name

For more information on what ARGS JetBackup 5 passes to other Hook Events, please visit: JetBackup 5 Hooks Documentation

After creating the Hook Script, be sure to make it executable by running the command chmod +x /Path/to/Hook/Script

Creating the JetBackup 5 Hook:

Now that the Hook Script is ready, we will Create the JetBackup 5 Pre Backup Account Hook. Please navigate to JetBackup 5 -> Hooks -> Create Hook to start. Below is the example configuration we have set for this Pre Backup Account Hook:

NOTE: We selected the specific Backup Job `Accounts with ETC Backups` in this case. If no Backup Jobs are selected, then the hook will apply to all Backup Jobs by default.

Running the Backup Job:

Before running the Backup Job, here is the current tree of the home etc folder we would like to backup:

[root@qa1 etc]# pwd
[root@qa1 etc]# tree
│   └── testfile
├── cacheid
├── ftpquota
└── testSymLink1 -> /root/testfilelinked

Next, we run the Backup Job and the following is the tree that will exist in the Backup itself:

[root@qa1 .jbetc]# pwd
[root@qa1 .jbetc]# tree
└── etc
    │   └── testfile
    ├── cacheid
    └── ftpquota

2 directories, 3 files

The etc directory now exists in the JetBackup Backup under the hidden directory .jbetc.

We hope you enjoyed this feature spotlight of custom hooks. If you are a Jetbackup user and have taken advantage of the custom hooks feature, please feel free to share your implementation with the rest of the JetApps community at: .