[nzlug] Folder synchronization software
Rex Johnston
spammeatyourperil at sclnz.com
Wed Aug 22 19:07:28 NZST 2007
Scott Newton wrote:
> going with unision rather than iFolder as it can be easily run from cron. I
> can then check the output email to see if there are any conflicts. So all I
> have in cron is:
>
> 0 6,18 * * * unison -ui text -terse -batch /my/folder ssh://x@y//other/folder
>
> Works like a charm.
Just for archive purposes, conflicts can be resolved automatically with
the likes of
unison -batch -numericids -owner -group -mergebatch 'Name * -> \
/usr/local/bin/conflict.sh "CURRENT1" "CURRENT2" "NEW"' /home/syncme/ \
ssh://x@y:1234//home/syncme/
where /usr/local/bin/conflict.sh looks like
#!/bin/bash
# $1 is local, $2 is remote file copied locally, $3 is new file
#echo $* >> /tmp/args
CUR1="$1"
CUR2="$2"
NEW="$3"
DIR=$(dirname "$CUR1")
FLOCAL=$(basename "$CUR1")
NEWNAME=$(echo "$FLOCAL" | sed -e 's/\.#unisonmerge1//')
cp "$CUR1" "$DIR"/REMOTE-"$NEWNAME"
chown blarg:users "$DIR"/REMOTE-"$NEWNAME"
chmod 777 "$DIR"/REMOTE-"$NEWNAME"
cp "$CUR2" "$NEW"
exit 0
# note extraneous stuff left in.
This will pop up renamed files rather than just site there and whinge.
Doesn't work properly on renamed directories for some reason.
Oh and unison has a weird bug. Try swapping the two directory specs if
you have any odd issues. I did have a go at fixing it but after a few
minutes of looking at the source code, my head said "Rex, you need a
glass of wine", and i never did return to it. It reminded me of my
(university(:prolog()))() days.
Cheers, Rex
More information about the NZLUG
mailing list