Home » Linux » Archive by category "Raspbian"

Duplicati – an alternative for Rackspace Cloud Files Sync

I’ve been using Rackspace Cloud Files Sync, a little piece of software I’ve written myself, for some years now. I use it to backup my photo’s and movies I’ve shot over the last decade or so. The thing I like about it is that it syncs your local folder with a Cloud Files container. When skipping content checksums it’s fairly fast to only process the changes. Aside from backing up files it can also restore them.

Whilst it still serves my need I get in trouble if or when Rackspace changes their Cloud Files API. Way back when I wrote the software I wrote it in BlitzMax with the MaxGUI module (using the excellent LogicGUI designer) and my own htbaapub.rackspacecloudfiles module. Sure, I can update my module that wraps the REST API but I no longer have an up to date BlitzMax with all the required modules set up on a PC. When I took Maximus offline the most convenient way to install BlitzMax modules and their dependencies disappeared. In short, it’ll be a big hassle to get a working setup again capable of compiling a new version of Rackspace Cloud Files Sync.

But today I found out about a software called Duplicati! Duplicati is backup software that can create and store backups to several kind of storage solutions such as Rackspace Cloud Files, Amazon S3, Windows Live SkyDrive, FTP, SSH and more. It can also encrypt your backups.

After a short test using Duplicati with Cloud Files I’ve at least found a nice alternative for when my Rackspace Cloud Files Sync stops working. The only thing I’m missing though is doing a full backup and then sync the changes like my software does, but it appears that this is already supported in the 2.0 preview release of Duplicati. So it’s likely that if or when my software stops working I can use the 2.0 release of Duplicati.

Using rsnapshot for daily PostgreSQL backups

Having done backups for MySQL using rsnapshot before I recently had to do the same thing for PostgreSQL. Turns out PostgreSQL has similar tools to do this and it’s actually quite easy to set it up.

First, assuming rsnapshot will run under the root user you’ll need to create a .pgpass file at /root/.pgpass that will hold the credentials that are required for setting up a connection with your database. The expected format is host:port:database:user:password, so for example:

localhost:*:mydbname:myusername:mypassword

With that in place create a shell script that will use this file and run the pg_dump program. Put it some place you can remember, e.g. /usr/local/bin/postgresql-backup.sh:

#!/bin/bash
export PGPASS=/root/.pgpass
pg_dump -w -h localhost -U myusername mydbname > postgresql-dump.sql
gzip postgresql-dump.sql

Again, just as with the using rsnapshot for daily MySQL backups article you need to configure rsnapshot.

Next is setting up /etc/rsnapshot.conf which is easy as well. At the end of this file you’ll find all the instructions of which directories to backup. Enter the next line. Do note that rsnapshot.conf uses a tab to separate values.

backup_script   /usr/local/bin/postgresql-backup.sh  postgresql/

To enable daily backups uncomment the next line:

#interval       hourly  6
interval        daily   7
#interval       weekly  4
#interval       monthly 3

To make rsnapshot run every day update /etc/cron.d/rsnapshot:

# 0 */4         * * *           root    /usr/bin/rsnapshot hourly
  30 3          * * *           root    /usr/bin/rsnapshot daily
# 0  3          * * 1           root    /usr/bin/rsnapshot weekly
# 30 2          1 * *           root    /usr/bin/rsnapshot monthly

Finally, try running rsnapshot. After it has run check your backup directory, which on Ubuntu 12.04 defaults to /.snapshots/. Be sure to mount /.snapshots/ on a separate drive. Because what use is it if your data drive contains your backup and decides to commit suicide?

$ sudo rsnapshot daily

Your PostgreSQL backup file should now be located at /.snapshots/daily.0/postgresql/postgresql-dump.sql. You can restore this file with the psql commandline utility.

Private Wiki – DokuWiki on Lighttpd

I had planned on setting up a private Wiki to use as a personal clipboard collection of useful snippets for some time now but never got around to it. This week I decided it was time to get it done and so I started searching for Wiki software. I ended up trying MediaWiki but ran into installation issues due to PHP’s session.save_handler not being set. After changing it I ran into more issues and with MediaWiki unable to store session data I couldn’t proceed. I’m not sure why MediaWiki requires this setting though as I run several WordPress websites and some other PHP code as well and they’re not having this issue.

Moving on I found out about DokuWiki which is really easy to install! Simply download the package, extract it and you’re done! It doesn’t require special database software such as MySQL – it stores pages on disk. Zero hassle and easy to use as well!

Since I’m not using Apache I can’t use .htaccess files. DokuWiki has a couple of folders which should not be exposed to the outside world. For Lighttpd my configuration looks like this:

$HTTP["host"] =~ "^wiki.example.com$" {
    server.document-root = "/home/example/wiki.example.com/httpdocs"
    # deny access completely to these
    $HTTP["url"] =~ "/(\.|_)ht" { url.access-deny = ( "" ) }
    $HTTP["url"] =~ "^" + "/(bin|data|inc|conf)/"  { url.access-deny = ( "" ) }
}

And you’re all set!

Installing HiPi on Raspberry Pi – Beware the date and time!

I’m currently in a small research group to see what the Raspberry Pi can mean for my school. Basically we’re checking out its features and capabilities. Our eventual goal is to create a remote controlled boat with a tracking camera on top of it.

Since Perl is my language of choice I decided to see what’s available already for programming the Raspberry Pi with Perl. It turns out there’s a distribution called HiPi (website) which seems to cover every possible interface the Raspberry Pi has.

Sadly I was having some issues in getting HiPi to install. When compiling the bcm2835 library the build process would fail. It turned out that the configure-process for bcm2835 detected that the files were newer than the date and time of the Raspberry Pi I was installing it to. This is something you’ll only find out if you try to install HiPi manually. When I was running the automated install script it wouldn’t give these details.

Luckily this can be fixed without any trouble. Just issue a date command like this:

$ date --set="2013-06-01T15:00"

Because the Raspberry Pi doesn’t come with a real-time clock it needs some help setting the time. You can also use NTP to keep the date and time of your Raspberry Pi updated, but this requires a network connection.