I want to rsync from a folder, which contanins index.php (which need to be excluded), and many other directories contains index.php too. i created an exclude file and added index.php there. but all the index.php files were gone. Is there any proper method to avoid the only file from syncing?
--exclude filter works like this:
If the pattern does not start with a slash, then it matches at the end of the path, anywhere in the tree.
--exclude myfile.txtmatches any file called
myfile.txtin any directory.
myfile.txtinside any directory called
If the pattern begins with a slash, it is anchored to the root of the transferred files.
To determine what the root of the transferred files is, remove everything after the last slash in the source path.
For example, in the following rsync command, the source path is
/srv/files/somethingand so the root of the transfer is
rsync -a /srv/files/something host:/backup/files/
So, to exclude source file
/srv/files/logs/myfile.txtyou would use
--exclude /logs/myfile.txt, where that slash at the start of the exclude pattern refers to the root of the transfer, which is rooted at
/srv/files/(on the source).