rsync 仅在日期和时间之后创建或修改的文件

发布于 2024-10-04 04:37:36 字数 753 浏览 0 评论 0原文

目标是仅同步(或使用任何其他提供所需结果的工具)在某个日期之后创建或修改的文件。

我在 OS X 10.6.5 上成功使用此命令: <代码>查找 . -newermt "2010-11-23 16:52:50" -type f -exec rsync -vuptn '{}' ../rsync_test/ ';' 我不认为 -newermt 可以在 OS X 之外的其他操作系统上运行。

此命令的问题在于,它对每个找到的文件运行 rsync 一次,但这似乎不是正确的方法。我尝试用 + 更改最后一个 ; ,以便它等待整个文件列表,但它会刹车(我确实尝试了 "+" ,\+ 等转义方式)。

背景:我正在尝试在远程位置备份我的文件。这些文件是大量原始照片和其他格式的照片(照片可以使用。每天大约 30GB),但由于上传带宽较小(ADSL 很糟糕),网络同步会花费不可用的时间。因此,我们的想法是在远程位置拥有大量磁盘空间,并每周一次在小型外部硬盘驱动器上传输新的/修改的文件。然后可以轻松地使用 rsync 在远程位置添加新的/修改的文件。为此,我需要在一周内同步外部硬盘驱动器上的新/修改的文件,因此我总是在远程位置为超过一周的文件保留每个文件的 2 个副本,或者在外部硬盘驱动器上为新的/修改的文件自上次运输以来。

我打算让这个命令每 10 分钟运行一次(cron),并显示上次运行的日期和时间。

你能修复我的命令吗? 或者您有更好的解决方案吗?

The goal is to rsync (or using any other tools that give the desired result) only files that are created or modified after a date.

I succeeded using this command on OS X 10.6.5:
find . -newermt "2010-11-23 16:52:50" -type f -exec rsync -vuptn '{}' ../rsync_test/ ';' I don't think -newermt is working on ohter OS than OS X though.

The problem with this command is that it runs rsync once per file found and that doesn't seems to be the proper way to do it. I tried to change the last ; with a + so it waits for the entire file list, but it brakes (I did try "+",\+ and other way to escape).

Background: I am trying to backup my files at a remote location. The files being a lot photos in raw and other format (photographs work. about 30GB per day), rsync'ing though the network would take unusable time due to small upload bandwidth (ADSL sucks). So the idea is to have a lot of disk space at a remote location and transporting new/modified files on a small external hard drive once a week. rsync can then easily be used to add the new/modified files at the remote location. For that I need to sync the new/modified files on an external hard drive during the week so I always have 2 copies of every files either at a remote location for files older than a week or on an external hard drive for new/modified files since the last transport.

I was going to make this command run every 10 minutes (cron) with the date and time from the last time it was run.

Can you fix my command?
Or do you have an even better solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

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

评论(3

辞慾 2024-10-11 04:37:36

我在服务器故障 并得到了我需要的答案。

--files-from=FILE 选项确实可以与 - 一起使用,因此它采用标准输入(其中 find 命令可以是使用然后通过管道传输到 rsync)。有关更多详细信息,请参阅服务器故障答案。

I posted the question again at Server Fault and got the answer I needed.

The --files-from=FILE option can indeed be used with a - so it takes the standard input (where the find command can be used and then piped to rsync). Look at the Server Fault answer for more details.

很快妥协 2024-10-11 04:37:36

我不知道您打算使用什么平台,但如果您想在 Powershell 中执行此操作,可以使用以下命令。

get-childitem -Recurse | where-object {$_.LastWriteTime -gt "2010/11/23 00:00:00"}

要让 rsync 执行您想要的操作,看起来您必须生成一个文件列表(从您的命令或我的命令),然后在 rsync 中使用 --files-from=FILE 选项(这样它将是两个命令)

I don't know what platform you're planning on using, but if you wanted to do this in Powershell you could use the following command.

get-childitem -Recurse | where-object {$_.LastWriteTime -gt "2010/11/23 00:00:00"}

To get rsync to do what you want it to it looks like you're going to have to generate a filelist (from either your command or my command) and then using the --files-from=FILE option in rsync (so it will be two commands)

ま昔日黯然 2024-10-11 04:37:36

默认情况下,rsync 不应删除文件,因此您只需将较小的硬盘驱动器 rsync 到较大的驱动器,rsync 将复制和更新任何文件,但不会删除丢失的文件。如果它似乎仍然删除,您可以尝试 --max-delete=0 选项。也许这会起作用。

Rsync shouldnt delete the files by default, so you can just rsync the smaller hard drive to the bigger drive and rsync will copy and update any files, but it wont delete the missing files. If it still seems to delete you can try the --max-delete=0 options. Perhaps that will work.

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