监视更改的远程路径

时间:2016-04-07 20:41:01

标签: monitoring rsync alternate inotify-tools

我已经创建了基于inotify-tools的简单脚本,但最后在我决定监视/ remotepath时,它是通过命令mount.cifs从NAS挂载的,它不起作用。

经过一些调查我发现信息后,inotify-tools不支持远程文件夹。

你是否有任何一个简单的工具可以让我有机会看到远程文件夹,如果有什么东西会改变,那么就会运行rsync。

也许我应该只使用rsync和仅使用新文件同步远程文件夹?

感谢任何想法。

与此同时,我创建了一些简单的bash脚本,这样做我想要的,但我与一个问题斗争,如果某些东西将从目标文件夹中删除,我不想再次同步这个删除的文件会发生什么。 知道如何解决这个问题吗?

#!/bin/bash

### Logs path
path="/var/log/compare"
log="compare.log"
listing1="listing1.log"
listing2="listing2.log"
### Path which will be monitored
destination="/path/to/destination/"
source="/path/to/remote/folder"


## Watching for content in source folder
ls -lh $source > $path/$listing1
### I`m checking if something was changed
        echo "$(date)" 'INFO' 'I will compare listing files' >> "$path/$log"
        if cmp -s "$path/$listing1" "$path/$listing2"
### Files are the same
        then
        echo "$(date)" 'INFO' 'Listings are the same' >> "$path/$log"
### Files are different
        else
        rsync -art $source $destination
        echo "$(date)" 'INFO' 'Finished synchronization' >> "$path/$log"
fi
cp $path/$listing1 $path/$listing2

0 个答案:

没有答案