0

I'm using Incrond to check a folder for file changes which triggers a Rsync job to our storage server. This configuration is deployed through Puppet, and therefore would like to use the $HOSTNAME variable in the destination path so it writes to it's own directory.

/path/to/backup/ IN_CLOSE_WRITE,IN_CREATE,IN_MODIFY,IN_MOVED_TO,IN_CLOSE_NOWRITE /usr/bin/rsync -t --password-file=/etc/rsyncd.secrets /path/to/backup/$# rsync://rsync@STORAGESERVER/storage/$HOSTNAME/backup/$#

However, this hostname variable is not available in Incrond; and just passes "hostname" into the rsync path.

How can I get the $HOSTNAME variable to work in Incrond?

1 Answers1

0

I would suggest this workaround :

Instead of triggering the actual rsync command, I would make incrond trigger a bash script execution containing the rsync command, and you will have the HOSTNAME command available in the script environment during its execution.

Obviously, you first have to deploy this script before, but as you're using puppet, it should not be the difficult part.

Chaoxiang N
  • 1,333