sync local and remote directories using rsync?
rsync is a one-way sync and it seems you want a two-way sync (files in both locations can change). There are other tools to do that -- unison is one.
- Unlike simple mirroring or backup utilities, Unison can deal with updates to both replicas of a distributed directory structure. Updates that do not conflict are propagated automatically. Conflicting updates are detected and displayed.
- Unison works between any pair of machines connected to the internet, communicating over either a direct socket link or tunneling over an encrypted ssh connection. It is careful with network bandwidth, and runs well over slow links such as PPP connections. Transfers of small updates to large files are optimized using a compression protocol similar to rsync.
- Unison is resilient to failure. It is careful to leave the replicas and its own private structures in a sensible state at all times, even in case of abnormal termination or communication failures.
- Unison is free; full source code is available under the GNU Public License.
rsync (despite having the name "sync") is only really one-way. You can have it delete files in the destination directory that don't exist in the source directory, but you can't simultaneously push and pull files both ways (you'll just need to run rsync again with the source and destination dirs swapped; I would recommend also the -u
option so that only newer files overwrite older ones).
See also: Rsync, two-way sync, and syncing file-deletion operations