我需要每分钟将记录的文件从3台服务器复制到一台数据存储器.我不需要保存原始文件 – 数据处理不在所有文件中.
但是当我使用选项–remove-sent-files时,rsync会发送并删除未完成(未关闭)的文件.
我试图阻止使用lsof和–exclude-from发送这些打开的文件,但似乎rsync并没有在exlude列表中取消完整路径:
--exclude-from=FILE read exclude >>patterns<< from FILE
lsof | grep /projects/recordings/.\\+\\.\\S\\+ -o | sort | uniq
/projects/recordings///2012-07-16 13:24:32.646970-.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不听exlude?