Repository navigation
Description
Synopsis
@Jwink3101 once noted in #5164 (comment)
There are two fundamental ways to do bi-sync:
- Compare each side independently to past state to develop a changelog. Propagate that change log
- Compare current state on each side using past state only for resolution (i.e. is this new on one or deleted on the other? Is it modified on one? Both?)
- Additional use for tracking renames though this isn't needed if you don't mind rclone's current approach requiring shared hashes or ModTIme
You are doing the first. This has the advantage of being robust to time differences but also breaks with rclone's current behavior of --modify-window and the more general behavior of looking at current state. With approach 2, you can handle ModTime's not agreeing and/or size and/or hash like regular rclone.
Prior discussions
#5164 (comment) (JWink3101)
From bisync docs:
Note that on some cloud storage systems it is not possible to have file timestamps that match precisely between the local and other filesystems. Bisync's approach to this problem is by tracking the deltas against saved state on each side separately, and then applying the resulting changes on the other side.
There are two fundamental ways to do bi-sync:
- Compare each side independently to past state to develop a changelog. Propagate that change log
- Compare current state on each side using past state only for resolution (i.e. is this new on one or deleted on the other? Is it modified on one? Both?)
- Additional use for tracking renames though this isn't needed if you don't mind rclone's current approach requiring shared hashes or ModTIme
Based on your comment, you are doing the first. This has the advantage of being robust to time differences but also breaks with rclone's current behavior of --modify-window and the more general behavior of looking at current state.
With approach 2, you can handle ModTime's not agreeing and/or size and/or hash like regular rclone.
The sub-bullet on the second is also interesting as it does allow you to track renames even if hashes aren't compatible. But you could also track with rclone's current behavior of looking at the extra files. Then use the past state to decide which side did the moving.
Approach 1 also requires the whole idea of --resync while it is implicit if you don't have past state in approach 2.
#5164 (comment) (ivandeex)
there are two fundamental ways to do bi-sync: ...
With approach 2, you can handle ModTime's not agreeing and/or size and/or hash like regular rclone.
Interesting. Sadly I'm not informed enough to discuss approaches now. It needs time to get literate :) Feels like switching to 2nd approach will mean a complete overhaul, but I'm not sure.
#5164 (comment) (ivandeex)
I really think it would have been better to [...] design the algorithm to be "rclonic"
The heart of rclone's omnivory change detection (runtime) lies around operations.equal, operations.checkHashes, et cetera. It's kept afloat by the astute test framework, in particular fstest.CheckListing, fstest.CheckHashes, fstest.CheckTime and [drums] retrying.
This code is not big in terms of LOC but its perceived complexity is high... while users continue to request for more change detection and filtering features.
My first approach to bisync about three months ago came across problems I can't clearly remember now so I tried it differently.
There is an ongoing proposal (#4810) that seeks to put this complexity under control. Ultimately we will need to inventory the state of affairs if we want to continue adding more features safely. I think we could continue this discussion in #4810. Maybe your experience in the synchronization field could help here?
when uncertain how to handle a situation, look at rsync. Is it worth the same idea with Unison?
Unfortunately rclone has already diverged (#1228, #3375, #5040, #5043, docs) from rsync :((
We can't easily fix that due to backwards compatibility concerns so there exists a waiting proposal (#4776) of rclone rsync besides rclone sync.
Mimicking Unison is a sound idea. However, if it would result in complete algorithm overhaul (not a critical problem) or if unison algorithms don't extend easily to the cloud world (that's worse), then I'd maybe think of developing an independent rclone unison.
#5164 (comment) (JWink3101)
One thing I toyed with when I first tried to make a two-way sync around rsync was to do two --dry-run calls A-->B and then B-->A. I then processed the actions and made my own decisions based on past state.
Could you do something like that but intrusive as opposed to a wrapper? The major downside of doing it from outside is two file listings but assuming the rclone structure allows, you can repeat it with the same listing. Then the initial compare implicitly follows the rclone logic as it stands today and in the future. And you end up with a lot fewer objects inside of your process since you've removed the ones that are the same.
This, BTW, also then aligns with what I called "method 2" for determining changes. (that is, being based first on current state rather than propagating changes. Both work but I still believe to be way more robust in the real world).
#5164 (comment) (cjnaz)
(Perhaps the rsync mode is a different algorithm, but assuming it applies to bisync...)
Regarding do two --dry-run calls A-->B and then B-->A, I think the change detection must be based on a prior state/history file/db/etc. This is needed in order to detect deletes. For rclonesync I considered making a single LSL file that represents both paths. This would have required generisizing this listing file format a bit and supporting mod-time tolerance. The value is limited - cuts memory usage, and designs out the possibility of divergence since both paths are compared to the same master history list. In rclonesync V3.2 I added a final compare of the final LSL files since the divergence bug did come up - actually triggered by an rclone bug in V1.52. Memory footprint can be a big deal. One rclonesync user had abut 2M files and ran out of memory. I optimized rclonesync to get it down to two in-memory file listings at any time. I understand that rclone deals with the file system recursively by directory rather than the whole tree?
#5164 (comment) (JWink3101)
I think the change detection must be based on a prior state/history file/db/etc.
Yes and no. I am not saying you don't need it for deletes. You do (as you note). But you do not need to detect changes and then propagate. That is what I referred to as method 1. The alternative (and I think much better and more robust) is to FIRST compare the current state and then use the previous state to detect whether it was a delete or a new file
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
Jwink3101 commentedon Oct 8, 2021
Wow. Lots of work putting this together and citing it.
I do not know golang but I am happy to contribute to any discussion.
If it helps, I started to put together my thoughts on my tool, syncrclone vs rclonesync-V2 and/or rclone bisync.
Also, this may be outdated and/or wrong. I will happily modify it.
Let's be 100% clear and upfront. I AM BIASED. I wrote syncrclone to fill a need not met by bisync.
This is just my comparison thoughts. I really do appreciate both and I think you should pick the one that works best for you and your use case.
The thing to remember is that bi-directional synchronization is fundamentally harder than mirroring because you need to keep the state. And therefore, it is also more opinionated.
--fist-synctype flags and bisync safety mechanisms. If they have never been synced before, you get the union of the two sides which is safer. No deletes. It also better matches how rclone currently does the comparisonbisync: bug fixes and new features including --create-empty-src-dirs …
Xelbayria commentedon Jul 14, 2023
I was doing some research to see if there are any software that have a better bisync, unfortunately, none of them have what I am looking because most of them use
hash,mtime, orsize. What I am looking for iscontent. Here is the detail below:Example
file#1 via Path1
file#1 via Path2
if both files'
mtimeis to be on the same day, but at different time OR The size of these 2 different File#1 are same. To have the same updated file on both path1 and path2. it would create conflict files "file#1..path1" and "file#1..path2".The key to merge the content of the 2 file is to create an algorithm that could compare the content of 2 files like so
file#1 via Path1
file#1 via Path2
the algorithm would see the similar content that don't need to be copied. it only need to copy the difference from Path2 to Path1 and delete the file via Path2, and copy the updated file to Path2
it would look like this:
File#1
The system above can be done the other way from Path1 to Path2, and then delete the File#1 via Path1 and copy the updated file.
My idea may not work for some cases but it could work for other cases. It depends. The Algorithm could take a lot of work to make it possible. There could be a different way (better than the idea above). Anyway, I gotta make a few changes to the way I use
rclone bisyncblc I just thought of a different way that could work for me.nielash commentedon Aug 20, 2023
It's an interesting idea, but it's hard to imagine this being workable for
Bisync, sinceBisyncneeds to also work for files that aren't text-based. For example, what would happen if you tried to merge the content of an image / audio / video / zip file? Very possibly some serious data corruption.You might consider checking out google/diff-match-patch, which might be closer to what you're looking for. It's the library that powers Google Docs and makes it possible for multiple users to edit a text document at the same time.
Xelbayria commentedon Aug 20, 2023
ah yes, I forgot about these types of files. I was only focused on text-based. Thanks for the info. I'll look into
google/diff-match-patchbisync: full support for comparing checksum, size, modtime - fixes rc…
bisync: full support for comparing checksum, size, modtime - fixes rc…
bisync: full support for comparing checksum, size, modtime - fixes #5679
Merge branch 'master' into ia-wt-1168
bisync: full support for comparing checksum, size, modtime - fixes rc…