linuxincron

Sub directory not getting copied to remote server using Rsync Linux


I tried with copying directory and files to remote Linux machine using rsync and incrontab.

It's working fine copying files to remote server.

Incrontab

/data/AMOS_SHARE/CHV_BE/ IN_MODIFY,IN_CREATE,IN_DELETE,IN_CLOSE_WRITE,IN_MOVE /data/AMOS/jboss/chv_rsync.sh

Rsync

#!/bin/bash
chmod -R 775 /data/AMOS_SHARE/CHV_BE
rsync -avuzh  /data/AMOS_SHARE/CHV_BE/ jboss@xx.xx.xx.xx:/data/AMOS_SHARE/CHV_BE/

I created some files in /data/AMOS_SHARE/CHV_BE/ folder. It worked fine as well as I created folder in that, it is also working fine. But whenever I creat files in a sub folder, it's not working.

Please help me out.


Solution

  • In incrond recursively monitoring is not implemented yet, so the events in sub-directories are not monitored. You can do it by adding a additional watchers to sub-dirs but I would recommended to use another tool:

    Watcher

    Also you can try ionotifywait tool (example)

    inotifywait /tmp/test_dir -m -r
    

    and parse the output of this command.