Sync Notebooks

pekcheey edited this page Apr 16, 2016 · 6 revisions
Clone this wiki locally

Since zim just works with plain text files to store all notebook data, syncing notebooks just comes down to syncing a folder with a bunch of files.

Alternatives to syncing:

Syncing files and folders using "cloud" services

There are programs and services which copy your data from your computer to the web storage and back. You select a data folder and run a daemon in the background. Your data will be copied to the cloud and synchronized all the time. You can read them and update from another computer. That's the way you can share you Zim notebooks between your desktop, notebook and/or netbook. Every time up to date, no flash discs or manual operation needed.

Which software

See also the Wikipedia overview of online backup services

How to Synch your zim Notebooks with Ubuntu One

Please note, the Ubuntu One service has been closed. The steps below could, with some small modifications, also be used to synch your notebook with Dropbox or comparable services.

You can synch single, multiple, or ALL of your zim notebooks. This example is for a single ZIM notebook folder called MAIN. Any folder, empty or otherwise, can become a ZIM notebook - it just has to have been 'added' using ZIM which will then create a notebook.zim file within that folder (this is currently a 5-line text file that contains the ZIM notebook name and the ZIM version number amongst other things).

From within Ubuntu

Both methods were tested, and Method Two is running on my Ubuntu 12.04 LTS. The only pre-requisites are that Ubuntu One is installed (it can be downloaded here) and that you are logged in to this service. If using the second method, additionally unison is required to be installed.

Method One

The simplest method. Do this first on your MOST up-to-date machine in terms of ZIM notes. Open a terminal, and at the $ prompt, type in the following commands where necessary (copy and paste is easiest). For the duration of this setup, please shutdown ZIM - including quitting any ZIM applications within the Notification Area.

This example assumes /home/my-username/MAIN is a single ZIM Notebook folder.

  • mkdir -p ~/Ubuntu\ One/My\ Stuff
  • mv ~/MAIN ~/Ubuntu\ One/My\ Stuff
  • Create a link back to original folder: ln -s ~/Ubuntu\ One/My\ Stuff/MAIN ~/MAIN

You can now restart ZIM. Any files or folders placed in the Ubuntu One folder will be automatically synchronised to those same files and folders located in your Ubuntu One storage CLOUD when you are online.

If you have completed this action on the first of your machines you should wait for a period of time for these files and folders to upload to the CLOUD. This time period is dependent upon how many files and folders/sub-folders you have and the speed of your internet connection. I'm often on a 3g network and would normally allow 20 minutes for an initial synchronisation.

Method Two

A slightly more complex method but perhaps more efficient in terms of block uploads to the CLOUD (on dial-up, 3g or other slow network services). This relies on using a scheduled cronjob that, at the specified interval, does a two-way sync between your specified ZIM notebooks and your Ubuntu One storage folder. Once online, your Ubuntu One folders will be sync'ed to the CLOUD.

I have previously used rsync to synchronise between folders but have since been informed that the author(s) of rsync do not recommend using rsync for this purpose. There are other solutions, of course, from FreeFileSync to unison. So I decided to use unison. On Ubuntu you first need to install unison. You can do that by opening a terminal and typing: sudo apt-get install unison Or by using the Software Centre.

For the duration of this setup, please shutdown ZIM - including quitting any ZIM applications within the Notification Area.

This example assumes /home/my-username/MAIN is your principal ZIM Notebook folder.

  • mkdir -p ~/Ubuntu\ One/My\ Stuff/MAIN
  • set up a user cronjob by typing: crontab -e
  • To set a thirty minute time period between the two-way rsync, copy and paste this to a single line in your crontab file: 0,30 * * * * /usr/bin/unison ~/MAIN ~/Ubuntu\ One/My\ Stuff/MAIN -silent -group -times -owner -ignorelocks > /dev/null 2>&1
    • Save and exit crontab
    • Let's execute an initial copy across rather than wait 30 mins for the cronjob to kick in, at the prompt, type: rsync -av ~/MAIN/ ~/Ubuntu\ One/My\ Stuff/MAIN/

You can now restart ZIM. Any files or folders that are sync'ed to the Ubuntu One folder will be automatically synchronised to those same files and folders located in your Ubuntu One storage CLOUD when you are online.

Please note that unison has very many options and you are advised to read the manual or, alternatively, type man unison at the command line.

If you have completed this action on the first of your machines you should wait for a period of time (worst case at least 30 minutes to allow the cronjob to fire) for these files and folders to upload to the CLOUD. This time period is dependent upon how many files and folders/sub-folders you have and the speed of your internet connection. I'm often on a 3g network and would normally allow 20 minutes + time-to-next-cronjob for an initial synchronization.

From within Windows

In a Windows environment one can use git and tortoise-git to syncronise the wiki via git.

From within Mac OS X

Anybody know how this is done? Please add to the wiki.

You can use unison as described above as well unison version 2.40.69 work great.

When using unison over ssh, one would want to configure the following ssh parameters:

  • ControlPath
  • ControMaster As well as to setup a public key based authentication.