每分钟我都需要将记录的文件从 3 个服务器复制到一个数据存储。我不需要保存原始文件 - 数据处理不在所有文件中。
但是当我使用 option 时--remove-sent-files
,rsync 发送并删除未完成(未关闭)的文件。
我试图阻止使用 and 发送这些打开的文件lsof
,--exclude-from
但似乎 rsync 并没有排除排除列表中的完整路径:
--exclude-from=FILE read exclude >>patterns<< from FILE
lsof | grep /projects/recordings/.\\+\\.\\S\\+ -o | sort | uniq
/projects/recordings/<uid>/<path>/2012-07-16 13:24:32.646970-<id>.WAV
因此,脚本如下所示:
# get open files in src dir and put them into rsync.exclude file
lsof | grep /projects/recordings/.\\+\\.\\S\\+ -o | sort | uniq > /tmp/rsync.exclude
# sync without these files
/usr/bin/rsync -raz --progress --size-only --remove-sent-files --exclude-files=/tmp/rsync.excldude /projects/recordings/ site.com:/var/www/storage/recordings/
# change owner
ssh storage@site.com chown -hR storage:storage /var/www/storage/recordings
那么,也许我应该尝试其他工具?或者为什么 rsync 不听排除?