This repository has been archived by the owner on Nov 20, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Intelligent Synching
kaspermarkus edited this page Sep 13, 2010
·
11 revisions
Intelligent synching is achieved through a combination of a database of md5 sums and rsync.
.last_sync a list of md5 sums after last sync
get lists of changes using rsync
use head and tail to avoid the garbage info from rsync
s_to_c: what is listed here exists on server, but is either not on, or in a different version on client
s_to_c=`rsync -vrc -n $GR_SERVER:$GR_SERVERROOT $GR_LOCALROOT | tail —lines=+ 2 | head —lines=-3`
c_to_s: What is listed here exists on local, but is either not on, or in a different version on server
c_to_s=`rsync -vrc -n $GR_LOCALROOT $GR_SERVER:$GR_SERVERROOT | tail —lines=+ 2 | head —lines=-3`
C_TO_S:
for each $entry (each line in c_to_s)
- if ($entry is a dir) — dir exists on local and not on server
- if ($entry is not in .last_sync)
- dir must have been created on local machine
- copy dir to server.
- Delete all sub-entries with dir from c_to_s
- else
- dir is in .last_sync
- dir must have been deleted on server
- if (md5($entry) != .last_sync md5)
- dir deleted on server, but has been changed locally
- CONFLICT
- else dir deleted on server and unchanged locally
- delete dir locally
*else it is a file
- delete dir locally
- if (file is not in s_to_c)
- it is a file, exists on local, not on server
- if (file is in .last_sync)
- file has been created locally
- sync to server
- else file deleted on server
- if (md5(file) != .last_sync md5)
- file deleted on server, but modified locally
- CONFLICT
- else file deleted on server, untouched locally
- delete locally
- if (md5(file) != .last_sync md5)
- else file exists in both places
- if (md5(local_file) != .last_sync md5)
- file changed locally
- if (md5(remote_file) != .last_sync md5)
- file also changed on server
- CONFLICT
- delete entry from s_to_c after resolved conflict
- else file only changed locally
- copy to server
- delete entry from s_to_c
- else file unchanged locally
- it is implied from the diff that it must be changed on server then
- cpy server to local
- delete entry from s_to_c
- if (md5(local_file) != .last_sync md5)
- if ($entry is not in .last_sync)
- If file is changed, created, update md5 for dir tree+file
- If file deleted_, change md5 from tree, remove entry from .lastsync
- If dir is changed, created, update md5 for dir tree
- If dir is deleted_, change md5 from tree, remove entry+subdirs/files from .lastsync