I have a bash script where I'm trying to copy some folders and archives in local with rsync. I have something like this:
RootFolder A B C D D1 D2 D3 . . . DN E F
What I want/do:
- Clean the Destiny Folder before start which I do with option
- Exclude some type of archives which I do with option
- Exclude some folders which I do with option
So until here I will have a copy Folders A, B, D and E.
But now I need to copy Only some subfolders in D and the list will change according to a list.
So Imagine I want:
A B D D2 D4 D8 E
I don't know how to do it as I've tried with
--include but I'm doing something wrong.
I'm doing something like:
rsync -av --delete --include=/D/D2 --include=/D/D4 --include=D8 --exclude=/C --exclude=/F RootFolder/ DestinyFolder
But It doesn't work well..... I've thought about doing some iterations or maybe I don't know if I could put all thee includes in a variable and pass it to rsync.
I have another doubt which is: As I get the destination Folder by param, what happens if the user uses "../" and I have the --delete option?? Will it delete the current folder? And if user just writes "/" will it delete everything?
RootFolder A File.txt .HidenFile B C D D1 D2 File.txt .HidenFile D3 . . . DN E F
I have something like
rsync -av --delete --include=/D/D2 --include=/D/D4 --include=D8 --exclude=*.txt --exclude=.* --exclude=/C --exclude=/F RootFolder/ DestinyFolder