using rsync to copy only certain folders within a directory structure
Hello,
I am trying to create a simple bash script to rsync some folders within a directory stucture. I am using wild cards, in the rsync source directory structure, but my command always fails. I believe it is the way I am using wild cards within my for loop. Here is my command ; Code:
for seq in `cat test.txt` ; do rsync -nvP /folder/folder/folder/folder/folder/**/$seq /folder/folder/folder/ ; done Thanks, ryjguy7 |
Do you expect ** to behave different from a plain *?
To get a list of source directories you could also build them beforehand by a find command. You want to have something like: Code:
$ find /folder/folder/folder -path "*suffix1" -o -path "*suffix2" |
You might also consider the --exclude and --include options of rsync (or --exclude-from and --include-from if you keep the pattern in a file). If you want to sync only some of the existing directories in a path, you can do something like:
Code:
rsync -av --exclude=* --include=dir1/ --include=dir2/ --include=dir3/ source destination Code:
rsync -av --exclude=dir1/ --exclude=dir2/ --exclude=dir3/ source destination |
If you really want to use a text file awk is probably the answer.
|
. . . Thanks for your responses and help guys.
Is there a way to tell the find command to search only for directories, and if so to create the directory structure it finds. Thanks, ryjguy7 |
The find command has a -type option. Using type -d you can search only directories. If you want to re-create a directory structure, you can use rsync, e.g.
Code:
rsync -av --include '*/' --exclude '*' source destination |
All times are GMT -5. The time now is 09:00 AM. |