Rsync如何包括目录但不包括文件? [英] Rsync how to include directories but not files?

查看:289
本文介绍了Rsync如何包括目录但不包括文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的目录结构和文件

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.txtb.txtc.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/

如何使用rsync和--exclude-from来执行此操作,而不指定每个文件夹,而是类似rsync -a data/* --exclude-from=exclude.rsync "" --onlyfoldersandnotfiles""的内容?

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""?

感谢帮助!

推荐答案

$ rsync -a -f"+ */" -f"- *" source/ destination/

这两个-f参数分别表示复制所有目录",然后不复制其他任何内容"."

"The two -f arguments mean, respectively, "copy all directories" and then "do not copy anything else"."

更多详细信息: http://psung.blogspot .com/2008/05/copying-directory-trees-with-rsync.html

这篇关于Rsync如何包括目录但不包括文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆