Rsync如何包含目录但不包含文件?
我有一个目录结构,像这样的文件
data/
data/a.txt
data/folder/
data/folder/b.txt
data/folder/folder/
data/folder/folder/c.txt
...
a.txt
、b.txt
和 c.txt
是计算机生成的大文件并且经常更新。它们不应该被备份 - 但我想备份目录结构:
data/
data/folder/
data/folder/folder/
如何使用 rsync 和 --exclude-from 执行此操作,而不指定每个文件夹,但类似于 rsync -a data/* --exclude -from=exclude.rsync "" --onlyfoldersandnotfiles""?
感谢您的帮助!
I have a directory structure and files like this
data/
data/a.txt
data/folder/
data/folder/b.txt
data/folder/folder/
data/folder/folder/c.txt
...
a.txt
, b.txt
, and c.txt
are large files that are computer-generated and renewed frequently. They should NOT be backuped -- but I want to backup the directory structure :
data/
data/folder/
data/folder/folder/
How can I do this with rsync and --exclude-from, without specifying every folder, but something like rsync -a data/* --exclude-from=exclude.rsync "" --onlyfoldersandnotfiles""
?
Thanks for help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
基本上,首先包含所有目录,然后排除所有文件。
Basically, first include all directories, then exclude all files.
“两个 -f 参数分别表示“复制所有目录”和“不复制其他任何内容”。
更多详细信息:http://psung.blogspot.com/ 2008/05/复制目录树-with-rsync.html
"The two -f arguments mean, respectively, "copy all directories" and then "do not copy anything else"."
Further details: http://psung.blogspot.com/2008/05/copying-directory-trees-with-rsync.html
过滤规则的意思是“排除不是目录的任何内容”。
Filter rule means "Exclude anything that's not a directory."
如果您想要同步除一个文件夹之外的所有内容,但仍想保留该排除文件夹的目录结构,您应该执行以下操作:
请参阅 排除列表 和 rsync 命令为例。
If you want to sync everything except one folder but you still want to keep the directory structure of that excluded folder, you should do the following:
See the exclude-list and the rsync command as an example.