tags:

views:

523

answers:

1

I have a dir with files and dirs in it. What I want is to make rsync copy of several folders from that dir. For example, lets say I have this:

/home/user
-- drwxr-xr-x  folderA
-- drwxr-xr-x  folderB
-- drwxr-xr-x  folderC
-- -rw-r--r--  file.1
-- -rw-r--r--  file.2

I want to copy folderA and folerB using rsync. I have created file rsync_folders.txt

+ /folderA/**
+ /folderB/**

My problem is that rsync will always copy file unless it matches exclude pattern. But if I add

- /**

nothing is copied because rsync first matches against exclude patterns.

Any ideas?

Note: I cannot list all folders and files I want to exclude. It will be changing from time to time.

A: 

Either use rsync -av src1 src2 src3 ... dst or put all the folders you want to rsync in a text file (each folder in a separate line) and use rsync -arv --files-from=sources.txt dst.
Note that by default -a implies --recursive but not when --files-from is used, so in this case -r must be specified explicitly.

spatz
Putting all folders in test file does not work for me cuz I am using several exclude and include rules already. rsync src1 src2 src3 works for me.
Georgy Bolyuba