Basic sync recipe

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Re: Basic sync recipe Sun Jul 06, 2014 7:52 am • by simon_a
Thanks, glad you're sorted. Like you I've found this to be a somewhat trickier exercise than had been anticipated; I'm a little out of my depth! so very happy to've achieved what I set out to do - for the time being at least.
simon_a
 
Posts: 6
Joined: Wed Jul 02, 2014 4:26 am

Re: Basic sync recipe Thu Jul 10, 2014 9:44 pm • by ThomasGeist
I got the basic sync recipe to work for me.

I want to sync a whole folder tree but exclude certain file types from being synced, however I could not find a way to do it.

Normally I have a rule that looks into subfolders and then a rule that ignores the filetypes ("Kind is <chosen file type>" -> ignore) but this does not seem to work with the basic sync rule which obviously grabs complete folders before any decisions for single files could be made.

How is this done?
ThomasGeist
 
Posts: 1
Joined: Thu Jul 10, 2014 9:26 pm

Re: Basic sync recipe Fri Jul 11, 2014 2:46 pm • by Mr_Noodle
You can't really do that. Sync is a full mirroring. If you want to have rules operate on a file-by-file basis, then you have to descend into subfolders (see sticky article) and apply rules to each file. The main problem with that approach is that files deleted at the source will not be deleted at the destination.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Basic sync recipe Tue Oct 21, 2014 6:13 am • by pvg
If it's a big folder tree, you may want to add a condition to do it less frequently, like "Date matched is not in the last 10 minutes", so that it doesn't bog things down. Alternatively, you can sync on a schedule using the Current Time attribute and get rid of all the conditions relating to date modified.


I'm deeply confused by 'Date last matched' - last matched for the whole recipe? for a particular subrule? If one wanted this to run, say, no more often than every 30 minutes, where does one add 'Date last matched'?

I ended up with this but it doesn't seem obvious that it's right. Image
pvg
 
Posts: 1
Joined: Tue Oct 21, 2014 5:53 am

Re: Basic sync recipe Tue Oct 21, 2014 3:10 pm • by Mr_Noodle
"Date last matched" is an attribute of the file being matched. In this case, it would be the folder that matches the rule. There's a subtlety here in that when checking date last matched of sub-files when using something like "any/all of its subfiles" is that it's actually using the date from the folder being matched by the rule as a whole. All the uses of date last matched in that rule refer to the same one.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Basic sync recipe Sun Jul 12, 2015 4:38 am • by polocanada
If you have 2 folders you need to sync in both directions:

1. You need to add both folders to watch in Hazel
2. You need to add the same rule to both folders, however, make sure you change the 2nd pair (target) folder in the settings of the rule.
3. As indicated previously you should set "Date Added is after Date Last Matched" & "Date Added is not in the last XX minute"
polocanada
 
Posts: 7
Joined: Sun Mar 29, 2015 2:26 pm

Re: Basic sync recipe Sun Jul 12, 2015 4:51 am • by polocanada
Hazel does what it is supposed to do and my understanding is Hazel is not a full sync application, it works on a simple principle of file mirroring..

This is just hypothetical.. but could these be potential issues?

1. Conflicting changes, e.g. when same file added to both locations and both locations are being watched and synced in both directions.

2. File changes e.g. The Hazel rule works fine for files added, but if it's set to watch for files being modified, wouldn't it lead to conflicts if the sync is in both ways in multiple pairs of folders being watched..
polocanada
 
Posts: 7
Joined: Sun Mar 29, 2015 2:26 pm

Re: Basic sync recipe Mon Jul 13, 2015 11:29 am • by Mr_Noodle
Hazel is not meant for two-way sync. I suggest looking into software specifically geared towards that as it's a bit more complex in terms of dealing with conflict resolution.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Basic sync recipe Thu Jul 30, 2015 12:06 pm • by mikestanley
I'm a new Hazel user (although I purchased back in January 2014 - just haven't gotten around to using till now) and I'm trying to sync a folder to 2 other folders. For my job I use a combination of OneDrive & Google Drive, and for my personal stuff I also pay for and use Dropbox. I have a "Work" folder on OneDrive that I consider my canonical copy of my work files and since I work on so many devices and like to have multiple copies of my data in case something bad happens, I want to sync that Work folder to Google Drive and Dropbox.

I'm OK with working only out of OneDrive and having Hazel sync to the other folders and have no need for changes to ever flow back the other way.

I downloaded the basic sync.hazelrules file and associated it with my OneDrive folder. This is what I have for Google Drive and it works just fine.

Image

I tried adding a second item in "Do the following" to point to the folder I want Work synced into on Dropbox, but that didn't seem to work (should it?), so I created a second rule for Dropbox.

Image

This rule only seems to work if I uncheck the Google Drive rule. There may be an obvious reason why, but I guess I'm missing it.

Is there a way to have both rules fire off whenever something is changed (within the limitation of "not in the last 10 minutes") ?

Do I need 2 rules, btw? Could I have crafted a single rule to have Work on OneDrive sync to first Google Drive, then Dropbox?

Also, I thought about just scheduling the sync to happen every X minutes, but it doesn't seem like that's possible - am I right?

Thanks for your help!
mikestanley
 
Posts: 5
Joined: Thu Jul 30, 2015 9:47 am

Re: Basic sync recipe Thu Jul 30, 2015 2:48 pm • by Mr_Noodle
By default, only one rule can match a file which is why having two rules won't work. You can work around that by using the "Continue" action. That said, having two actions in the same rule should work. How long does the sync take? I'm wondering if it takes longer than 10 minutes. Why not just have that be "date modified is after date last matched" so that it catches any changes that happens since last time?

If after fixing that, it doesn't work, check the logs. Go to the "Info' section and click "View Log" to see what happened.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Basic sync recipe Thu Jul 30, 2015 5:02 pm • by mikestanley
Thanks for the quick response. The sync is near instant, btw. I'm on a brand new 2015 MBP with an SSD in it, and I'm only changing one folder name. Even if it copied all the files it wouldn't take long, as it's about 1.2GB and 625 items.

Here's what I've done so far. I disabled the Dropbox rule and am only working with the Google Drive rule.

I added another Do action to Sync into the Dropbox folder UT_Work_Documents, right under the Google Drive folder.

I also changed the 10 minutes condition to what you suggested - "date modified is after the date last matched" - although for some reason the syncs were running instantly anyway.

To test this I'm simply renaming a folder in the Work folder on OneDrive to testing1, 2, 3, etc. When I do that, with the Do actions in this order:

Google Drive
Dropbox

The Google Drive folder is synced, but the Dropbox folder is not. When I move the Dropbox folder to the top, it is synced, and the Google Drive folder is not.

I just ran this three times so I could generate some logs. The weird thing is the log SAYS it can't sync to the Dropbox folder, but it definitely does. But it stops and does not then sync to the Google Drive folder. Here are the logs from the last 3 tries:

2015-07-30 16:50:41.854 hazelworker[6356] Processing folder OneDrive
2015-07-30 16:50:43.967 hazelworker[6356] Work: Rule Sync OneDrive Work Folder to Google Drive & Dropbox matched.
2015-07-30 16:50:44.059 hazelworker[6356] [Error] Could not sync file/folder: Could not sync file/folder at Work to /Users/poet/Dropbox/UT_Work_Documents/Work.
2015-07-30 16:50:44.059 hazelworker[6356] Sync returned error status: 23
2015-07-30 16:50:44.065 hazelworker[6356] Done processing folder OneDrive
2015-07-30 16:52:30.047 hazelworker[6362] ###main load address: 0x108695000
2015-07-30 16:52:30.048 hazelworker[6362] ###Noodle load address: 0x1087a6000
2015-07-30 16:52:30.048 hazelworker[6362] ###CK load address: 0x10876c000
2015-07-30 16:52:30.215 hazelworker[6362] Processing folder OneDrive
2015-07-30 16:52:32.332 hazelworker[6362] Work: Rule Sync OneDrive Work Folder to Google Drive & Dropbox matched.
2015-07-30 16:52:32.423 hazelworker[6362] [Error] Could not sync file/folder: Could not sync file/folder at Work to /Users/poet/Dropbox/UT_Work_Documents/Work.
2015-07-30 16:52:32.423 hazelworker[6362] Sync returned error status: 23
2015-07-30 16:52:32.429 hazelworker[6362] Done processing folder OneDrive
2015-07-30 16:56:01.305 hazelworker[6370] ###main load address: 0x106fea000
2015-07-30 16:56:01.305 hazelworker[6370] ###Noodle load address: 0x1070fb000
2015-07-30 16:56:01.305 hazelworker[6370] ###CK load address: 0x1070bd000
2015-07-30 16:56:01.471 hazelworker[6370] Processing folder OneDrive
2015-07-30 16:56:03.582 hazelworker[6370] Work: Rule Sync OneDrive Work Folder to Google Drive & Dropbox matched.
mikestanley
 
Posts: 5
Joined: Thu Jul 30, 2015 9:47 am

Re: Basic sync recipe Thu Jul 30, 2015 5:07 pm • by mikestanley
As an aside... could I have Hazel monitor OneDrive and sync to Google Drive, and also monitor Google Drive, and sync it to Dropbox? Seems like it would get the job done, just A -> B -> C instead of A -> B & A -> C.
mikestanley
 
Posts: 5
Joined: Thu Jul 30, 2015 9:47 am

Re: Basic sync recipe Fri Jul 31, 2015 9:06 am • by mikestanley
mikestanley wrote:As an aside... could I have Hazel monitor OneDrive and sync to Google Drive, and also monitor Google Drive, and sync it to Dropbox? Seems like it would get the job done, just A -> B -> C instead of A -> B & A -> C.


Probably obvious to everybody else, but the answer to this question turned out to be yes. Since that solves my problem, just a slightly different way, I'm going with that method. I'm curious why the sync to 2 folders didn't work, but it's not a big deal since the other way works.
mikestanley
 
Posts: 5
Joined: Thu Jul 30, 2015 9:47 am

Re: Basic sync recipe Fri Jul 31, 2015 2:45 pm • by Mr_Noodle
The error would stop execution so anything after it won't be run. Try turning on debug mode (see sticky article on that) and see what the actual error is. It might be some thing where it couldn't copy over the metadata.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Basic sync recipe Fri Jul 31, 2015 5:12 pm • by mikestanley
Ok, I re-enabled the rule that tries to sync OneDrive to Google Drive, and as an additional Do action in the same rule, Dropbox. Renamed my "testing" folder and the sync to Google Drive worked, but not Dropbox. I triggered the rule again a couple minutes later to make sure I had the debug logs for a complete set, and here it is.

Looks like it thinks it failed to sync to Google Drive (but it didn't) and never tried to sync to Dropbox?


2015-07-31 17:07:09.817 HazelHelper[346] DEBUG: Thread 0x61800007b900: Received events (
{
date = "2015-07-31 21:07:09 +0000";
path = "/Users/poet/OneDrive/Work/";
shouldDoFullScan = 0;
}
) for stream at path: /Users/poet/OneDrive
2015-07-31 17:07:09.817 HazelHelper[346] DEBUG: Thread 0x61800007b900: Run worker for folder: /Users/poet/OneDrive
2015-07-31 17:07:09.843 hazelworker[2339] ###main load address: 0x10d743000
2015-07-31 17:07:09.844 hazelworker[2339] ###Noodle load address: 0x10d857000
2015-07-31 17:07:09.844 hazelworker[2339] ###CK load address: 0x10d81c000
2015-07-31 17:07:09.853 hazelworker[2339] DEBUG: Program is licensed.
2015-07-31 17:07:09.860 hazelworker[2339] DEBUG: Could not read Mail preferences.
2015-07-31 17:07:09.879 hazelworker[2339] DEBUG: Error reading file /Users/poet/Library/Application Support/Firefox/prefs.js: Error Domain=NSCocoaErrorDomain Code=260 "The file “prefs.js” couldn’t be opened because there is no such file." UserInfo=0x7fc1705184c0 {NSFilePath=/Users/poet/Library/Application Support/Firefox/prefs.js, NSUnderlyingError=0x7fc170517fa0 "The operation couldn’t be completed. No such file or directory"}
2015-07-31 17:07:09.885 hazelworker[2339] DEBUG: Could not find entry for default_directory in Chrome preference file.
2015-07-31 17:07:09.890 hazelworker[2339] Processing folder OneDrive
2015-07-31 17:07:09.890 hazelworker[2339] DEBUG: Initialized
2015-07-31 17:07:09.890 hazelworker[2339] DEBUG: Pausing to wait for things to settle down.
2015-07-31 17:07:11.983 hazelworker[2339] DEBUG: Processing directories: (
"/Users/poet/OneDrive"
)
2015-07-31 17:07:11.985 HazelHelper[346] DEBUG: Checking events for path /Users/poet/OneDrive, folder <ComNoodlesoft_HazelConcreteFolder: 0x610000276f00> "OneDrive"
2015-07-31 17:07:11.986 hazelworker[2339] DEBUG: Received file event: {
date = "2015-07-31 21:07:09 +0000";
path = "<ComNoodlesoft_NoodlePathSet: 0x7fc1705199d0> - (\n \"/Users/poet/OneDrive/Work\"\n)";
}
2015-07-31 17:07:11.986 hazelworker[2339] DEBUG: About to process directory /Users/poet/OneDrive
2015-07-31 17:07:11.987 hazelworker[2339] DEBUG: .DS_Store: File is hidden/invisible. Skipping.
2015-07-31 17:07:11.988 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/BingClients. File/folder not part of change set/file event.
2015-07-31 17:07:11.988 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/Documents. File/folder not part of change set/file event.
2015-07-31 17:07:11.988 hazelworker[2339] DEBUG: Icon
: File is hidden/invisible. Skipping.
2015-07-31 17:07:11.988 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/OLD_Documents. File/folder not part of change set/file event.
2015-07-31 17:07:11.988 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/oldDocuments. File/folder not part of change set/file event.
2015-07-31 17:07:11.989 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/Outlook. File/folder not part of change set/file event.
2015-07-31 17:07:11.989 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/Personal. File/folder not part of change set/file event.
2015-07-31 17:07:11.989 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/Pictures. File/folder not part of change set/file event.
2015-07-31 17:07:11.989 hazelworker[2339] DEBUG: Skipped /Users/poet/OneDrive/Share. File/folder not part of change set/file event.
2015-07-31 17:07:11.993 hazelworker[2339] Work: Rule Sync OneDrive Work Folder to Google Drive matched.
2015-07-31 17:07:11.993 hazelworker[2339] DEBUG: Got error last time. Re-trying actions.
2015-07-31 17:07:12.052 hazelworker[2339] DEBUG: == Sync output ==
.d..t....... Work/
*deleting Work/testing8/
.f........x. Work/Notebooks/Fixes and Reference.url
.f........x. Work/Notebooks/Systems Architecture.url
rsync: rsync_xal_set: sys_lsetxattr failed: >>Work/Notebooks/Fixes and Reference.url>>com.apple.quarantine>>: Permission denied (13)
rsync: rsync_xal_set: sys_lsetxattr failed: >>Work/Notebooks/Systems Architecture.url>>com.apple.quarantine>>: Permission denied (13)
cd++++++++++ Work/testing00/
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1044) [sender=3.0.7]

== End sync output ==
2015-07-31 17:07:12.053 hazelworker[2339] [Error] Could not sync file/folder: Could not sync file/folder at Work to /Users/poet/Google Drive/Work.
2015-07-31 17:07:12.053 hazelworker[2339] Sync returned error status: 23
2015-07-31 17:07:12.053 hazelworker[2339] DEBUG: Tapping error retry sequence
2015-07-31 17:07:12.054 hazelworker[2339] DEBUG: Writing out DB file: /Users/poet/OneDrive
2015-07-31 17:07:12.080 hazelworker[2339] DEBUG: Directory /Users/poet/OneDrive processed in 0.094018 seconds
2015-07-31 17:07:12.081 HazelHelper[346] DEBUG: Checking events for path /Users/poet/OneDrive, folder <ComNoodlesoft_HazelConcreteFolder: 0x610000276f00> "OneDrive"
2015-07-31 17:07:12.081 hazelworker[2339] DEBUG: Sending metrics to scheduler. Next scheduled run: 2015-07-31 18:07:12.053
2015-07-31 17:07:12.082 HazelHelper[346] DEBUG: Received metrics for folder /Users/poet/OneDrive: {
directoryDepth = 0;
requestedSchedulingTime = "2015-07-31 22:07:12 +0000";
triggerPaths = "<ComNoodlesoft_NoodlePathSet: 0x600000032200> - (\n)";
unavailablePaths = "{(\n)}";
}
2015-07-31 17:07:12.082 HazelHelper[346] DEBUG: Timer scheduled for folder /Users/poet/OneDrive at 2015-07-31 22:07:12 +0000
2015-07-31 17:07:12.082 hazelworker[2339] Done processing folder OneDrive
mikestanley
 
Posts: 5
Joined: Thu Jul 30, 2015 9:47 am

PreviousNext

Return to Support