I'd like to use rsync to...
- delete files on the receiving side that were also deleted on the sending side
- not delete other files that are in the rsynced directory on the receiving side
For example, let's say I have a directory local-src:
BEFORE: local-src locally contains...
a.txt
b.txt
c.txt
my remote directory that I'd like to sync to contents of local-src to is called remote-src.
BEFORE: remote-src remotely contains...
a.txt
b.txt
c.txt
d.txt
README.md
Let's say that I delete some files in local-src:
AFTER LOCAL DELETE: local-src locally contains...
c.txt
How can I use rsync in a way to ensure that the files deleted at the source are also deleted at the destination, but without deleting other files at the destination. For example, I'd like to have the following at the destination:
AFTER LOCAL DELETE: remote-src remotely contains...
c.txt
d.txt
README.md
That is, a.txt and b.txt are remotely deleted as well, but d.txt and README.txt are left alone.
Is there any way to achieve this with rsync?
EDIT: The verdict seems to be that this might be impossible with rsync. I've been asked why I need this, so to illustrate my use-case:
Let's say I have a web server. On that web server, I've got a bunch of directories, let's say that I have a directory A and a public_html directory that my site is served from. Let's say that I have some automated process that produces files in directory A. I'd like to rsync (or sync using some other tool) the files generated or updated in A to the public_html directory, without deleting other arbitrary files that might be within public_html. I certainly don't want rsync to to accidentally delete my website.
If rsync isn't the tool for this job, does someone else know how I can do this?
rsyncas there is no way to know which files where already in the remote folder. You might need to find out another tool. – Spack May 22 '13 at 21:02