Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oneechan69

macrumors 6502
Original poster
Mar 29, 2022
270
32
US
TLDR: I want to sync an iCloud directory on my Mac with another folder on the Mac not on iCloud, continuously so if I edit an file on either folder, the changes are immediately reflected on the other one. I want to be able to exclude all sub-directories except ones I explicit allow, perhaps by specifying files or folders to ignore, like a .gitignore file or Syncthing's .stignore.

I want to sync two folders on my mac on the same drive: one folder in iCloud, and one stored locally / not on iCloud. I don't want to have the files only in iCloud because there's no option to keep files offline, it only streams files when you open / try to access them. I have a folder like this stored locally:
  • Folder1
  • Folder2
  • file1.md
  • file2.md
And would like to only sync the non-folder files, and specific folders to the iCloud directory, and ignore the rest of the folders. I would to be able to exclude all sub-directories except ones I explicit allow, perhaps by specifying files or folders to ignore, like a .gitignore file or Syncthing's .stignore.

I want to sync an iCloud folder and a local one for my Obsidian vault (markdown notes), If I edit a note on the local folder on my Mac, its immediately reflected in the iCloud folder. If I edit a note stored on iCloud from my iPhone, by the time I use my Mac again, the iCloud folder syncs or finished syncing with the local folder. For me iCloud has been mostly good with syncing changes between devices in the background like that.

However, I don't want to store my entire vault in iCloud because it would eventually pass the 5GB limit, iCloud only streams files, and I've lost revisions made on my iPhone a few times due to poor syncing / handling of sync conflicts (fortunately I recovered them in Obsidian, it has a feature to keep backups of revisions for up to a week).
I'll take suggestions for GUI apps, but I would prefer a CLI, I just feel like I could trust that more.
 
rsync doesn't sync files continously though. Does chronosync do so?
It looks like Chronosync can be configured to do this. From their webpage:

1684708811825.png
 
  • Like
Reactions: sahnert
Chronosync is my suggestion too. It is about the only GUI based app which allows complex selection of files and folders which I think is required by your selection requirements. But it will take some fiddling with inclusion and exclusion rules to get what you want.

Make sure you have a good backup before you start messing with sync of iCloud!
 
Last edited:
This could be done with MaOS’s folder actions.
  1. Launch Automator on your Mac.
  2. Click File > New, select Folder Action, and hit Choose to create a new Folder Action in Automator.
  3. You’ll see a dropdown menu that says Folder Action receives files and folders added to at the top. Use this dropdown to select the source folder where the files to be moved are located.
  4. On the left of your screen where it says Actions, search for the action named Move Finder Items and drag and drop it onto the workflow on the right.
  5. In the Move Finder Items action on the right, select the destination folder from the To dropdown menu. This is where your files will be moved to.
  6. Tick Replace existing files if you want.
  7. Press Command + S, enter a name for your Folder Action, and click Save.
  8. Close Automator.
From now on, whenever you place a file in your source folder, Automator will move the file to the destination folder.
 
Last edited:
I may be wrong, but don't folder actions work when a file is added to folder. What happens when a file is modified? And what about 2-way sync? I think both these are wanted by the OP.
You simply e.g. filter the files for “Date last modified” from the Automator actions. I mean, you can easily add Applescript or run e.g. a rsync shell script to the Folder Action which should allow for whatever more complicated scenario.

If anything, I think that changing the tag of a file is something which is not easily detected on macOS (can chronosync that?), but whatever else should not be a problem.

Thinking about it, looking into using launchd might be an elegant solution for the described scenario. 🤓

EDIT: @Oneechan69 you want to sync deletes too? Then incorporating a unison-script is an option.
 
Last edited:
You simply e.g. filter the files for “Date last modified” from the Automator actions. I mean, you can easily add Applescript or run e.g. a rsync shell script to the Folder Action which should allow for whatever more complicated scenario.
Easier would be to use Hazel which is a serious step up from Folder Actions. But even Hazel Help warns that 2-way sync in not safe unless you take great pains to detect conflicts and the Help even suggests that Chronosync is the better solution. So in ascending levels of sophistication you have Folder Actions, Hazel, and Chronosync.

Of course you can write your now software (I don't think AppleScript is the way to go for 2-way sync), but why do that when others have already done it?
If anything, I think that changing the tag of a file is something which is not easily detected on macOS (can chronosync that?)
Yes, Chronosync detects changes in Tags (and other Extended Attributes). You really won't find a more powerful way of managing synchronisation on a Mac.
Thinking about it, looking into using launchd might be an elegant solution for the described scenario. 🤓

EDIT: @Oneechan69 you want to sync deletes too? Then incorporating a unison-script is an option.
Honestly, I think you are needlessly piling up the complications.
 
  • Like
Reactions: FreeThinker_64
Honestly, I think you are needlessly piling up the complications.
Mmh, the problem of the OP is basically solved in 2 lines of shell script:

rsync -rtuv /path/to/folder_a/* /path/to/folder_b
rsync -rtuv /path/to/folder_b/* /path/to/folder_a

Indicating that you can use launchd besides Folder Actions to run this and asking about additional requirements (which might require a different tool) does not add to complications in my book. YMMV
 
FreeFileSync and its tool RealTimeSync (see link below about It) can help you
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.