关于 Rsync 的两个问题 - 按日期和按文件名进行 rsync

发布于 2024-08-30 19:54:20 字数 278 浏览 7 评论 0原文

我有两个关于 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神妖 2024-09-06 19:54:20

这是 #1rsync -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 #1rsync -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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文