7

I use rsync in the following manner:

rsync -Pvaz [email protected].*.***:Documents/ /Users/me/Documents/
rsync -Pvaz /Users/me/Documents/ [email protected].*.***:Documents/ 

The problem: if I delete a file on my home computer and sync, it doesn't get deleted on the remote computer. Is there a way to use rsync to literally sync two folders?

1
  • This question tipped me how to sync my computer at home and my home directory in the office without bothering about server names etc. of my connection at home. Namely, just swap source and destination...
    – Dror
    Commented Feb 8, 2012 at 9:34

2 Answers 2

16

Man page for rsync:

 --delete                delete extraneous files from dest dirs
 --delete-before         receiver deletes before transfer (default)
 --delete-during         receiver deletes during xfer, not before
 --delete-delay          find deletions during, delete after
 --delete-after          receiver deletes after transfer, not before
 --delete-excluded       also delete excluded files from dest dirs
9

I am not a rsync expert and there may be a switch that can do what you want and someone else may say.

However, personally, I use rsync when I need one way copying. When it comes to synchronise two locations, I use Unison which is built on top of Rsync and basically makes it easier.

3
  • Unison is not built on top of rsync, unless you give a very unusual meaning to the phrase. It implements an algorithm similar to rsync (ie. partial checksums) in its own way. This has practical implications: unison's implementation is written in Ocaml, and as contributors to questions similar to this one have already noted, it is unfortunately very sensitive to versions - not only versions of unison itself on both sides, but also to the version of Ocaml it's built with. Often you'll be OOL unless you go to 1. compile Ocaml from source, and then 2. compile unison from source.
    – q.undertow
    Commented May 16, 2022 at 1:57
  • I'm personally fond of unison— I keep forgetting how to do a safe bidirectional rsync (and thus always lose a few files on my first attempt), while with unison I rarely get any issues. Granted, the warning by @q.undertow is quite true, and even the Unison maintainer(s) alert to that issue. Unison has little visibility, and, as such, package managers are often out of sync (pun intended!) with the latest and greatest versions, which can result in serious problems! Commented Dec 19, 2022 at 11:14
  • On the other hand... you can always go with rclone instead :) It's natively compiled (via Go) to pretty much anything out there, connects to any protocol (OneDrive, Google Drive, and a gazillion others), and, these days (2022, that is), most definitely is the Swiss Army Knife of remote file sync. unison continues to be maintained (for two decades now!), but rclone is solid and been around since 2013. Commented Dec 19, 2022 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .