Experiment with SSHFS
To be honest Zim Wiki is not all fancy with cloud-sync and multi-device support but following the Unix Philosophy of doing just one thing and doing it well, helps me to organize and retrieve information that is valuable to me.
There was a time when I use to back up my copy of Zim on dropbox. Now, in order to maintain a single source of truth, I use to sync the copy of my Zim notes to dropbox every minute using a cronjob.
The thing that goes wrong is if the cronjob fails for whatever reason, or I shut down the device before cron job and that will land me up in a conflicting situation.
These problems pushed me to come up with a slightly better management system.
What is sshfs
I didn't know I could mount a filesystem of a VPS on my local system. Previously, I use to use either scp or rsync to transfer files from and to the remote machine. SSHFS is a filesystem client that can help to mount files and directories on the remote server to your local machine.
This is a revelation to me because now I can use my remote server as a centralized place to serve my zim-wiki.
How to achieve sshfs backup
This is very simple, first, we need to install
sshfs on the local machine.
sudo apt install sshfs
Then we need to mount the remote files and directories in a pre-existing directory.
sudo sshfs -o nonempty,reconnect,allow_other,default_permissions,IdentityFile=<ssh-private-key> <user>@<hostname>:/path-to-remote /local-path
And now we can just
rsync zim-wiki files by:
rsync -avzh ~/zim-notes/notebooks ~/aws-vps/zim-wiki/
Make sure that directories are synced. Now just open zim-wiki and add the notebook. :)
When internet connection goes down, the application will start hanging in that case first we need to kill the
sshfs process and then unmount the directory.
sudo pkill -kill -f "sshfs"
And then unmount the directory
sudo fusermount -u /home/aws-vps
I have tried to accommodate the
erratic connection in mind and introduce
reconnect option in sshfs. This arrangement has workout miracles for me in terms of management.