对 rsync 传输的文件进行排序
我们当前正在使用 rsync
来运行备份作业。 这项工作需要几个小时。 由于备份的某些部分比其他部分更重要,因此我们希望确保在其他所有内容之前备份它们(即 rsync 首先传输这些文件)。 使用 rsync --files-from 可以轻松完成此操作。
不幸的是,我们需要优先考虑的文件与单个目录中的所有其他文件一起(平面层次结构,嘘!),它们只有一个特定的扩展名来识别它们。 因此,我们希望获取 rsync
传输的文件列表,在本地对其进行排序,然后使用以下命令将其传递给 rsync
rsync --files-from
。
使用 rsync -v --dry-run 可以让我们完成大部分工作(我认为),但会显示目录添加和文件属性更改,这意味着我们并没有真正获得立即可用的列表。
所以,我的问题是:如何从 rsync 获取要使用的文件列表?
We're currently using rsync
to run a backup job. This job takes several hours. As there are some parts of the backup that are more important than others, we would like to ensure that they are backed up before everything else (i.e. that rsync
transfers those files first). This should be easily accomplished using rsync --files-from
.
Unfortunately, the files that we need to prioritise are alongside all of the other files in a single directory (flat hierarchy, boo!), they just have a specific extension to identify them. As such, we'd like to get a list of the files that rsync
would transfer, sort it locally and then pass it to rsync
using rsync --files-from
.
Using rsync -v --dry-run
gets us most of the way there (I think), but displays directory-additions and file property changes, meaning we don't really get an immediately usable list.
So, my question is this: how can I get a list of files to use from rsync?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会对@alberge的答案发表评论,但我没有足够的声誉:-
(@Daniel,如果您使用单独的
rsync
命令,我可以建议使用for循环:只需一个rsync如果您想要进行任何更改,则需要更改命令以及要同步的易于管理的列表。for 语句中的顺序是它们的使用顺序。
I would have commented on @alberge's answer but I don't have enough reputation :-(
@Daniel, if you are using separate
rsync
commands might I make a suggestion to use a for loop:just one rsync command to alter should you want to make any changes and a nice easy managable list of things to sync. The order in the for statement is the order in which they are used.
您可以先使用rdiff-backup,或者只是将rsync替换为rdiff-backup。 例如,您可以通过以下方式获取文件列表:
但是,我会接受其他建议来尝试两次传递。 另外,您是否尝试过启用压缩?
You could use rdiff-backup first, or just replace rsync with rdiff-backup. For example, you can get you list of files with:
However, I'd go with the other suggestion to try two passes. Also, have you tried enabling compression?
运行 rsync 两次可以吗? 即对高优先级文件运行一次,对其余文件运行一次?
Would running rsync twice work? i.e. run it once for the high-priority files and once for the rest?