I have been working on this for several days and no matter what I do I can't get it to work. I've read practically every Q&A on StackExchange network about rsync but still not found the answer.
Basically I am writing a website deploy tool and it uses rsync to move files from a source Git repo to deploy Git repo; the destination. Committing to the deploy repo actually deploys the code to the web server so I am delaying with rsync between two different directories.
It is very important that any files that the developer deleted in the source repo also get deleted in the deploy repo. However, there are selected files that are in the deploy repo that need to not be deleted Specifically this are files that the hosting provider provides and are needed in production but that are problematic to maintain in the source repo.
I understand from what I have read in
man, here, and elsewhere that if I add the names of the files that are in the deploy/destination repo that I want to keep to an
Here is what I am doing, basically:
rsync --archive --verbose \ --exclude ".git" --exclude ".git*" \ --exclude-from="/tmp/excludes.txt" --delete-after \ /dir/to/source/repo/ \ /dir/to/deploy/repo
And for example purposes let's say this is the contents of
Now when I have tried this using a trivial example locally it always seems to work as expected. But when I use it with CircleCI in a real-world deploy scenario,
rsync always deletes
/foo/bar/baz.php after running the above command.
Can you see what I am doing wrong? Thanks in advance.
UPDATE - THE ABOVE DOES WORK
Turns out the logic in my script running in CircleCI was at fault, and I just could not see it. I was running multiple rsync commands with different roots (essentially subdirectories of my main root) because of different rules needed, and one list of exclude files with filepaths that were all based on the main root. Ugh.
Anyway dear reader, the upshot is that the above example indeed works as I describing how I wanted it to work.