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.
The rsync tool allows you to exclude certain file types when synchronizing data. Use an asterisk * followed by the extension of the file type you want to exclude. For example, you may want to back up a directory that contains many .
Rsync (Remote Sync) is the most commonly used command for copying and synchronizing files and directories remotely as well as locally in Linux/Unix systems.
So if you are running this sort of command frequently, and the set of changed files is small relative to the total number of files, you should find that rsync is faster than cp.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With