The directories option in the Wazuh FIM module accepts only literal paths e.g. /etc, /var/log and so on.
It does not parse input as regex, so anchors like ^ (which mean "start of string" in regex) are treated as invalid characters rather than pattern operators.
So replace <directories realtime="yes">^/etc/file.bak</directories> with <directories realtime="yes">/etc/file.bak</directories>Realtime monitoring applies to both directories and files.
For directories, it monitors all files within the specified directory, including creation, modification, and deletion events. However, it does not detect the creation of the directory itself, as the directory already existed prior to enabling monitoring.
The same principle applies to individual files. Only modification and deletion events are monitored because the file was created before the FIM configuration was applied.
The configuration you applied above monitors the entire /etc directory but limits event detection to the file.bak file.