Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rsync excluding everything except 1 directory tree

Tags:

linux

rsync

I have a directory structure with a variable number of subdirectories and files. I would like to exclude everything EXCEPT 1 subdirectory tree.

I have tried

rsync -a --include 'wanted_dir' --exclude '*' 1/ 2/

but it gives me just the wanted_dir directory (none of the files under it).

like image 474
user1751044 Avatar asked Oct 16 '12 19:10

user1751044


1 Answers

To include all files within your directory, add the triple stars :

rsync -a --include 'wanted_dir/***' --exclude '*' 1/ 2/
like image 60
slumbering Avatar answered Oct 29 '22 20:10

slumbering