Rsync how to include directories but not files?

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 often generated and updated by the computer. They should NOT be backup, but I want to back up the directory structure:

 data/ data/folder/ data/folder/folder/ 

How to do this with rsync and --exclude-from, without specifying each folder, but something like rsync -a data/* --exclude-from=exclude.rsync "" --onlyfoldersandnotfiles"" ?

Thanks for the help!

+15
linux backup rsync
Aug 23 '10 at 8:55
source share
2 answers
 $ rsync -a -f"+ */" -f"- *" source/ destination/ 

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

Further information: http://psung.blogspot.com/2008/05/copying-directory-trees-with-rsync.html

+21
Feb 11 '12 at 18:33
source share
 rsync -a --include='*/' --exclude='*' source/ destination/ 

Basically, include all directories first, then exclude all files.

+7
Nov 14 '16 at 10:13
source share



All Articles