关于 Rsync 的两个问题 - 按日期和按文件名进行 rsync
我有两个关于 rsync 的问题:
1:我有一堆文件,这些文件按一年中的某一天递增。例如:file.txt.81、file.txt.82 等。现在,这些文件位于不同的目录中:
data1/file.txt.81 数据1/文件.txt.82 数据2/文件2.txt.81 data2/file2.txt.82
我怎样才能让rsync只获取*.82文件,甚至不接触其他文件
2:现在我有一个与上面类似的数据目录结构。如何同步在特定日期或之后修改的所有文件?
谢谢
I have two questions with respect to rsync:
1: I have a bunch of files which are incremented by day of the year. Ex: file.txt.81, file.txt.82, etc. Now, these files are in different directories:
data1/file.txt.81
data1/file.txt.82
data2/file2.txt.81
data2/file2.txt.82
How can I have rsync get only the *.82 files and not even touch the other files
2: Now I have a similar data directory structure as above. How can I rsync all files that have been modified on or after a specific day?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 #1
rsync -avz --include "**/" --include=*.82 --exclude=* /path/from /path/to
的答案这将递归地(- a) 包含目录并在其中搜索任何与 .82 匹配的内容并排除其他内容。您可以在
man rsync
中找到更多信息,并查找“排除模式”对于#2,我会找到一些方法来使用 find 和 mtime 来做到这一点。要查找过去 60 分钟内修改过的名为 *.82 的文件,应该可以使用以下命令:
sudo find /path/from -mmin 60 -type f -name *.82
已编辑:反引号太多
Here is the answer for #1
rsync -avz --include "**/" --include=*.82 --exclude=* /path/from /path/to
This will recursively (-a) include the directories and search them for anything matching .82 and exclude everthing else. You can find more info on this in
man rsync
and look for "exclude patterns"For #2 I would find some way to do it with find and mtime. To find files modified in past 60 minutes with the name *.82 this should work:
sudo find /path/from -mmin 60 -type f -name *.82
EDITED: too many backticks