Unison server

One of the utility type programs that I use all the time is Unison. It does a very nice job of synchronizing two directories including propagating deletes.

I use Unison for synchronizing podcasts between my Ubuntu 8.04 server (running bashpodder) with my MP3 player (a Sansa Clip).

To optimize the synchronization process, it is recommended to run Unison as a server (on the server). I have been using this configuration for over six months by manually starting the Unison service after any reboot. Since my server only gets rebooted when there is a power failure, this hasn't been an issue.

In the process of moving bashpodder to a newer server, I decided to get Unison setup to automatically start on boot. To do that, I wrote the attached bash script and saved it in the /etc/init.d/ directory. Of course you should set the file ownership and permissions using:
sudo chown root:root unison
sudo chmod +x unison

Then to configure the boot and shutdown scripts, you can execute:
sudo update-rc.d unison defaults

This will setup the server to handle its side of the synchronization.

On my Ubuntu 9.10 laptop, I have a script that executes this command in the terminal.
unison /media/0123-4567/PODCASTS socket://192.168.198.10:2222//home/kevin/public/podcasts/episodes -ui text -batch -perms 0 -fastcheck true
Of course you will need to modify this for the IP address of your server and the path to the directories that you want to sync.

Please post a comment if you have any improvements or suggestions for this process.

Files: