how to rsync ex/include select specific directories ?
I am trying to set up some rsync scripts, and have been successful. However, now I want to instruct rsync to copy files in specific directory to limit the backup that will happen over a slow link.
my source structure is: /data /data/a/b/c/1 /data/m/n/o/p/2 I want to sync only files within folder b and files within folder m. [1,2 are files] While I have re/read man rsync many times, and --dry-run with at least 100 combinations, I either get the whole tree copied, or I get no files copied. One test gave me folder b and it's files, but also copied files in folders below the required folder. In other web answers, there seems to be some tricks like **, and including then excluding the same directoy, but still no success. rsync --dry-run -az --exclude-from=exclude.lst --include-from=include.lst /data/ remote:/data/ it made sense to me to excude all: * but include: /a/b/* /m/* Any pointers, or exact in/exclude list setup would be very welcome ? |
here is one way to achieve -
Well, looked like nobody has done this before, so eventually I worked it out. Note: using separate include - nogo. also, - in either file is supposed to be an exclude. but i couldn't make it work, bettter with just a single exclude.
cmd: rsync --dry-run -az --exclude-from=exclude.lst /data/ remote:/data/ exclude.lst: #dont backup outlook pst files they/re huge - *.pst - *.PST #files in folders b, not subfolders + /a + /a/b + /a/b/* ## note use ** at end of previous line to do b and all files/folders below it. #files in folder/ms, not subfolders + /m + /m/* #dont back up anything else (that hasn't already been mentioned) - * Now I get a single rsync run that backs up (to a remote internet machine) just the most inportant stuff...it is a slow link after all, with the stats option listing the file / change d and transmitted file sizes. Chime in if there is a simpler way, or even just to say thanks... |
All times are GMT -5. The time now is 08:09 PM. |