How to use rsync’s –ignore-non-existing flag

rsyncsynchronization

I want to keep two directories "in sync" such that the local version may contain only a subset of the remote version. So, syncing them up should result in any changes to the local subset being pushed to the remote directory, and any changes to the remote directory, that are made to the relevant subset, being pulled in to the local directory. However, I don't want any new files or directories being pulled from the remote directory without them being explicitly copied.

(The reason I want to do this is because I have a very large music collection on a remote server, but I cannot fit the entire collection on my laptop at once, for lack of disk space. However, I'd like to keep whatever portion of the collection, that I do have here locally, synchronized with the relevant portion on the server, particularly for cases where I've updated ID3 tags, Vorbis comments, etc.)

rsync's --ignore-non-existing flag seemed like a reasonable way to do this, from its documentation in the man page, but it did not yield the expected results. It skips over the first level of sub-directories, even though both root directories contain the same children.

E.g., if remote directory example.org:/path/to/it/ contains dir1 and dir2, and local directory /other/dir/ contains dir1 and dir2, I get the following results…

$ rsync --dry-run --ignore-non-existing example.org:/path/to/it/ /other/dir/
skipping directory .

Or trying it with a wildcard…

$ rsync --dry-run --ignore-non-existing example.org:/path/to/it/* /other/dir/
skipping directory dir1
skipping directory dir2

Does anyone know how to properly use this flag? Or am I misunderstanding its purpose? Or, if you have any other suggestions for keeping a subset of a directory in sync, please let me know.

Thanks. 🙂

Best Answer

Try doing it recursively:
rsync --recursive --dry-run --ignore-non-existing example.org:/path/to/it/ /other/dir/