Saturday, January 30, 2010

File Synchronization between N78 and PC

My Nokia N78 have no WIFI support and local GPRS/3G data connection fee is quite high, so I can not synchronize large amount of data between N78 and PC with cloud service. I use N78 disk mode USB link to synchronize, details are as follow. Tested in Debian (gnome version 2.28).

In fact, this is not N78 specific, and can be used to sync files with any devices mountable in Linux.

Setup gnome auto-mount VFAT options

Traditionally VFAT file system is case insensitive, but can preserve case optionally, on the other hand, Linux native file system is case sensitive. So VFAT should be mounted in case sensitive mode for synchronizing software to work properly.

Gnome auto-mount VFAT options can be setup as follow:

Start gconf-editor (System tools -> Configuration editor), check key: /system/storage/default_options/vfat/mount_options, make sure there is "shortname=mixed" instead of something like "shortname=lower" (default value for some distributions) in the value. And "iocharset=utf8" should be set in mount_options too.

Setup autorun upon USB connecting

In gnome, open nautilus-file-management-properties (System -> Preferences -> File management), select tab named "Media", for media handling, set "Open Autorun Prompt" for "Software" media. I have thought gnome-volume-manager will be responsible for autorun script execution, but that is turned off in Debian, and autorun mechanism in nautilus is used instead.

Create a file named ".autorun" in the root directory of the N78 micro-SD card. This is the synchronization script.

Unidirectional synchronization via rsync

Rsync can be used for unidirectional synchronization, such as backup some directories (photos, notes etc) from N78 to PC or push some directories (music, podcast etc) vice versa.

One issue here is that VFAT time resolution is not enough for rsync. This can be fixed via specifying "—modify-window=2" in command line.

Bidirectional synchronization

It seems that unison can be used for bidirectional synchronization. But I have not tried it. Unidirectional synchronization is enough for me.

My autorun script

.autorun in N78


/usr/local/bin/autorun_sync N78



echo "Usage: $prog <media>"

prog=$(basename $0)

if [ $# -lt 1 ]; then
echo -n "Press any key to continue:"
exit -1



echo "----------------------------------------------"
echo -n "Rsyncing ..."
rsync -rutv --delete --modify-window=2 $odir/* $mdir/

if [ -f $ldir/ ]; then
while read d p; do
if [ -z "$d" ]; then
rsync -rutv --modify-window=2 $p $mdir/$d $idir/
done < $ldir/
echo "Done!"
echo "----------------------------------------------"
echo -n "Syncing ..."
echo "Done!"
echo "----------------------------------------------"
echo -n "Unmounting ..."
umount /media/$media
echo "Done!"
echo "----------------------------------------------"
echo -n "Done! press any key to close:"



1 comment:

Anonymous said...

nice post. thanks.