Archive for February, 2008

Hacking my Buffalo TeraStation Live to support rdiff-backup

Friday, February 1st, 2008

I’ve been searching for cost-effective and reliable backup software to replace Retrospect, which I’ve been using to back up my mixed network of Macs, PCs and linux systems. I’ve been using Retrospect for almost twenty years, but it has long-standing bugs, and in my use takes about 12 hours to back up three systems. I’ve also had problems with rebuilding catalogs, which can easily take several days or more.

Recently, I purchased a 2-TB Buffalo TeraStation Live, configured with four 500-GB drives in a RAID-5 configuration, for use primarily as backup storage. It came with a copy of Memo Live Agent which I’ve set up to do automatic incremental backups from my Mac to an AFP share on the TeraStation, in parallel with Retrospect. I’m very impressed: it was easy to set up, has an agent that monitors file activity so things are instantly backed up, and when the restoration process is way faster than Retrospect.

But I need a backup solution for my linux server, and rdiff-backup is definitely the way to go. But the TeraStation only supports CIFS, Appletalk and FTP for remote access, which are not suitable remote mounts for backing up my linux server. Fortunately, there are a few hacks available that allowed me to gain root access to the TeraStation to enable secure shell so the TeraStation could be mounted as a File System in User Space.

Hacking the TeraStation

  • I downloaded acp-commander to enable telnet so I could log in as root.
  • In searching around, I found that the TeraStation includes secure shell daemon, although it is not enabled at boot. It’s a simple matter to start it:
  • root@TOTHEPT_NAS1:/etc/init.d# /usr/local/sbin/sshd

  • I want secure shell to start up at boot time, so I edited /etc/init.d/rcS and inserted a new startup script, /etc/init.d/sshd.sh, in step 3 of the boot process:
  • #
    echo "** step3 **"
    for cmd in diskmon.sh drivecheck.sh sshd.sh atalk.sh ftpd.sh httpd.sh lprng.sh smb.sh pcastd.sh epg.sh directcopy.sh clientUtil_servd.sh lsprcvd.sh daemonwatch.sh cron.sh ltboo
    do
    exec_sh $cmd
    done

  • I used the Buffalo startup script format as a template for starting up secure shell:
  • wmconlon@TOTHEPT_NAS1:~$ cat /etc/init.d/sshd.sh
    #! /bin/sh
    #
    KIND="sshd"
    RETVAL=0
    # this is used by daemonwatch
    ACTIVE_FILE=/var/run/active_sshd
    SSHD=/usr/local/sbin/sshd
    #
    configure()
    {
    ## configure files from Buffalo parameters.
    echo "configure"
    }
    #
    start()
    {
    echo "start"
    echo -n $"Starting $KIND services: "
    $SSHD
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd || \
    RETVAL=1
    touch $ACTIVE_FILE
    #return $RETVAL
    #
    }
    #
    stop()
    {
    echo "stop"
    echo -n $"Shutting down $KIND services: "
    rm -f $ACTIVE_FILE
    if [ -n "`pidfileofproc $SSHD`" ] ; then
    killproc $SSHD -TERM
    else
    failure $"Stopping $KIND"
    fi
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sshd
    echo ""
    #
    return $RETVAL
    }
    #
    restart()
    {
    stop
    sleep 1
    start
    }
    #
    reload()
    {
    echo -n $"Reloading $KIND "
    if [ -n "`pidfileofproc $SSHD`" ] ; then
    killproc $SSHD -HUP
    else
    failure $"Reloading $prog"
    fi
    #
    RETVAL=$?
    return $RETVAL
    }
    #
    # Usage statement.
    #
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    restart
    ;;
    reload)
    reload
    ;;
    *)
    echo "usage: $0 {start|stop|restart|reload}"
    exit 1
    ;;
    esac

  • I then added a backup user to the TeraStation and a hidden share that would only be accessible via ssh_fs.
  • I figured I might as well use the TeraStation’s daemon monitor, so I appended this line to /etc/daemonwatch.list:
  • /var/run/sshd.pid /var/run/active_sshd /etc/init.d/sshd restart

  • Finally, I restarted the TeraStation to make sure the secure shell daemon would start when rebooted.

On my server

  • First I installed the fuse package:
  • [root@white /]# yum install fuse-sshfs

  • Now I mounted the TeraStation as a remote file system (it asks for a password):
  • [root@white /]# sshfs backup_user@TeraStation: /mnt/TeraStation

  • And then I tested a backup, such as:
  • [root@white /]# rdiff-backup /etc/ /mnt/TeraStation/etc
    Warning: hard linking not supported by filesystem at /mnt/TeraStation/etc/rdiff-backup-data

Now that it all works, I just need to set up some shell scripts to run my backups under cron. Then I can retire Retrospect.