PHP/MySQL-based Solution for Blog

While I’ve found NanoBlogger to be extremely intuitive and easy to deploy, I’ve come to the realization that bash and co. simply don’t scale well with lots of entries, and that they aren’t nearly as effective as other database-querying solutions.

On one of my sites in particular, $ nb update all took all of 10 minutes to complete - this was with a ‘quick’ 2-line hack of the display template. Pitiful performance for something I once thought was lean and mean - though I should have known that from the start.

I’m also entertaining the idea of using a perl-based CMS called BlazeBlogger. It’s reportedly very fast at serving static files, and as it is based on Perl, does not require a database. From BlazeBlogger’s About page:

BlazeBlogger is a simple to use but capable CMS for the command line. Being written in Perl as a cross-platform application, and producing static content without the need of database servers or server-side scripting, it is literally a CMS without boundaries suitable for a wide variety of web presentations, from a personal weblog to a project page, or even a company website.

Find/Cpio Data Between Partitions

Besides the Dump/Restore method mentioned here, I’ve found the commands find and cpio an equally effective combo when used to obtain true clones of data directories.

In the below example, the source partition is mounted at /srcDir, and the destination partition device is /dev/targetPart. We will create two scratch directories at /var/tmp: srcDir, and targetDir; and mount both source and target partitions here.

We will use the mount_nullfs file system as opposed to the traditional loopback file system. From man 8 mount_nullfs:

The mount_nullfs file system differs from a traditional loopback file system in two respects: it is implemented using a stackable layers techniques, and its “null-node��?s stack above all lower-layer vnodes, not just over directory vnodes.

# mkdir /var/tmp/srcDir && mount_nullfs /srcDir /var/tmp/srcDir

# mkdir /var/tmp/targetDir && mount /dev/targetPart /var/tmp/targetDir

# cd /var/tmp/srcDir

# find . | cpio -pdum /var/tmp/targetDir

# cd - && umount /var/tmp/targetDir && umount /var/tmp/srcDir

# rmdir /var/tmp/{srcDir,targetDir}

Dump/Restore Data Between Partitions

Here’s a script I created to backup and restore data between partitions on OpenBSD:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
newfs /dev/ad1s1a
newfs /dev/ad1s1e
newfs /dev/ad1s1f
mount /dev/ad1s1a /backup/root
mount /dev/ad1s1e /backup/var
mount /dev/ad1s1f /backup/usr
( dump -0f - / ) | ( cd /backup/root ; restore -rf - )
( dump -0f - /var ) | ( cd /backup/var ; restore -rf - )
( dump -0f - /usr ) | ( cd /backup/usr ; restore -rf - )
umount /backup/root
umount /backup/var
umount /backup/usr
tunefs -n enable /dev/ad1s1a
tunefs -n enable /dev/ad1s1e
tunefs -n enable /dev/ad1s1f