Ubuntu – rsync exclude a single file from the root folder

command linersync

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?

Best Answer

rsync uses directories relative to the root rsync folder. You should be able to achieve this using something like

rsync -aAX ./ ../target --exclude=/index.php

The "/" will indicate the root directory.