Running TiddlyWiki on Node.js

TiddlyWiki is an awesome personal wiki, but if you have
found this page then you probably already know that. Either you know me
personally, and I won’t stop talking about it, or you have searched for
TiddlyWiki explicitly and don’t need me to tell you about it.

I have been using TiddlyWiki to keep track of just about everything for the last
couple of years, from packing lists to general research notes. Here is my setup,
which makes it accessible everywhere, secure, and backed-up.

In the following examples I will use the name “mynewwiki”, but you should
replace this with a better name.

Installing TiddlyWiki on Node.js

The official
instructions for
setting up TiddlyWiki on Node.js are actually very complete, but if you find any
gaps let me know. I am running on an Ubuntu Server, so I installed Node and NPM
through apt.

$ node -v
v4.2.6
$ npm -v
3.5.2

Next, install TiddlyWiki itself and create an instance.

sudo npm install -g tiddlywiki
tiddlywiki mynewwiki --init server

Daemonize TiddlyWiki

By default TiddlyWiki does not come with any mechanism for starting
automatically. As of Ubuntu 15.04, daemons are primarily stared with systemd
and the following script will daemonize TiddlyWiki. To use it, set the path to
your installation and pick a username and password. Finally, set the system user
which should run TiddlyWiki.

Proxy through Apache

The above script launches the server with a username and password, however you
should absolutely not expose that unsecured like it is now. To secure my
connection to the server I proxy through Apache with mod_ssl enabled and
a free certificate from LetsEncrypt.

Setup Backups

There is a plugin for TiddlyWiki
which provides some basic versioning, but I prefer to roll my own versioning and
backups. I use cron to automatically tar the full contents of my TiddlyWiki
every 15 minutes. The md5 hash of this archive file is then compared to the
previous archive and is only kept if the hashes are diffent. Here’s the script: