# HG changeset patch # User Dominique Corbex # Date 1220991502 -7200 # Node ID 14003687d2b82a45d3e5c11d0f94be83a4dce251 # Parent d5be027602ddc8500f8182b3dc122a9cecc4f7d9 Add: BoxBackup automatic on-line backup system diff -r d5be027602dd -r 14003687d2b8 boxbackup-client/description.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxbackup-client/description.txt Tue Sep 09 22:18:22 2008 +0200 @@ -0,0 +1,22 @@ +BoxBackup Client (bbackupd) + +BoxBackup is designed to be easy to set up and run, and cheap to use. +Once set up, there should be no need for user or administrative +intervention, apart from usual system maintenance. + +bbackupd is configured with a list of directories to back up. It has a +lazy approach to backing up data. Every so often, the directories are +scanned, and new data is uploaded to the server. + +The daemon is always running, although sleeping most of the time. In +lazy mode, it is completely self contained - scripts running under cron +jobs are not used. + +If an old version of the file is present on the server, a modified +version of the rsync algorithm is used to upload only the changed +portions of the file. + +After a new version is uploaded, the old version is still available +(subject to disc space on the server). Similarly, a deleted file is +still available. The only limit to their availability is space allocated +to this account on the server. diff -r d5be027602dd -r 14003687d2b8 boxbackup-client/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxbackup-client/receipt Tue Sep 09 22:18:22 2008 +0200 @@ -0,0 +1,80 @@ +# SliTaz package receipt. + +PACKAGE="boxbackup-client" +VERSION="0.10" +CATEGORY="network" +SHORT_DESC="Client for the BoxBackup on-line backup system" +MAINTAINER="domcox@users.sourceforge.net" +DEPENDS="db libedit openssl perl zlib" +SOURCE="boxbackup" +WANTED="boxbackup-server" +WEB_SITE="http://www.boxbackup.org/" + +# Configuration variables +CONF_DIR="/etc/box" +DATA_DIR="/var/lib/bbackupd" +RUN_DMON=0 + +# Rules to gen a SliTaz package suitable for Tazpkg +genpkg_rules() +{ + _pkg=$WOK/$WANTED/${SOURCE}-$VERSION/parcels/boxbackup-${VERSION}-backup-client-linux-gnu + mkdir -p $fs/usr/bin + cp -a $_pkg/bb* $fs/usr/bin + mkdir -p $fs/etc/init.d + cp -a stuff/bbackupd $fs/etc/init.d +} + +# Pre and post install commands for Tazpkg + +pre_install() +{ + # Stop daemon + if [ -e /var/run/bbackupd.pid ]; then + /etc/init.d/bbackupd stop + RUN_DMON=1 + fi +} + +post_install() +{ + # Creating conf dir + if [ ! -e $CONF_DIR ]; then + mkdir -p $CONF_DIR && chmod 755 $CONF_DIR + fi + if [ ! -e $DATA_DIR ]; then + mkdir -p $DATA_DIR && chmod 700 $DATA_DIR + fi + # Start daemon (if stopped by install) + if [ $RUN_DMON -eq 1 ]; then + /etc/init.d/bbackupd start + fi +} + +# Pre and post remove commands for Tazpkg + +pre_remove() +{ + # Stop daemon + if [ -e /var/run/bbackupd.pid ]; then + /etc/init.d/bbackupd stop + fi +} + +post_remove() +{ + # Delete DATA directory + rm -rf $DATA_DIR + + # Delete Client config files + rm -rf $CONF_DIR/bbackupd* + + # Delete CONF dir (if empty) + if [ `ls $CONF_DIR | wc -l` -eq 0 ]; then + echo -n "Removing $CONF_DIR..." + rm -rf $CONF_DIR + status + fi + # Delete PID, sock files + rm -f /var/run/bbackupd.* +} \ No newline at end of file diff -r d5be027602dd -r 14003687d2b8 boxbackup-client/stuff/bbackupd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxbackup-client/stuff/bbackupd Tue Sep 09 22:18:22 2008 +0200 @@ -0,0 +1,55 @@ +#!/bin/sh +# /etc/init.d/bbackupd: Start, stop and restart bbackupd deamon on SliTaz, at boot +# time or with the command line. +# +# To start daemon at boot time, just put the right name in the $RUN_DAEMONS +# variable of /etc/rcS.conf and configure options with /etc/daemons.conf. +# +. /etc/init.d/rc.functions +. /etc/daemons.conf + +NAME=BBackupd +DESC="BoxBackup deamon" +DAEMON=/usr/bin/bbackupd +OPTIONS=$BBSTORED_OPTIONS +PIDFILE=/var/run/bbackupd.pid + +case "$1" in + start) + if [ -f $PIDFILE ] ; then + echo "$NAME already running." + exit 1 + fi + echo -n "Starting $DESC: $NAME... " + $DAEMON $OPTIONS > /dev/null + status + ;; + stop) + if [ ! -f $PIDFILE ] ; then + echo "$NAME is not running." + exit 1 + fi + echo -n "Stopping $DESC: $NAME... " + kill `cat $PIDFILE` + status + ;; + restart) + if [ ! -f $PIDFILE ] ; then + echo "$NAME is not running." + exit 1 + fi + echo -n "Restarting $DESC: $NAME... " + kill `cat $PIDFILE` + sleep 2 + $DAEMON $OPTIONS > /dev/null + status + ;; + *) + echo "" + echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]" + echo "" + exit 1 + ;; +esac + +exit 0 diff -r d5be027602dd -r 14003687d2b8 boxbackup-server/description.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxbackup-server/description.txt Tue Sep 09 22:18:22 2008 +0200 @@ -0,0 +1,37 @@ +Server for the BoxBackup on-line backup system. + +Box Backup is an open source, completely automatic, on-line backup system. +It has the following key features: + + * All backed up data is stored on the server in files on a filesystem - + no tape, archive or other special devices are required. + + * The server is trusted only to make files available when they are + required - all data is encrypted and can be decoded only by the + original client. This makes it ideal for backing up over an untrusted + network (such as the Internet), or where the server is in an + uncontrolled environment. + + * A backup daemon runs on systems to be backed up, and copies encrypted + data to the server when it notices changes - so backups are continuous + and up-to-date (although traditional snapshot backups are possible too). + + * Only changes within files are sent to the server, just like rsync, + minimising the bandwidth used between clients and server. This makes it + particularly suitable for backing up between distant locations, or over + the Internet. + + * It behaves like tape - old file versions and deleted files are available. + + * Old versions of files on the server are stored as changes from the + current version, minimising the storage space required on the server. + Files are the server are also compressed to minimise their size. + + * Choice of backup behaviour - it can be optimised for document or server + backup. + + * It is designed to be easy and cheap to run a server. It has a portable + implementation, and optional RAID implemented in userland for reliability + without complex server setup or expensive hardware. + +Box Backup is distributed under a BSD license. diff -r d5be027602dd -r 14003687d2b8 boxbackup-server/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxbackup-server/receipt Tue Sep 09 22:18:22 2008 +0200 @@ -0,0 +1,180 @@ +# SliTaz package receipt. + +PACKAGE="boxbackup-server" +VERSION="0.10" +CATEGORY="network" +SHORT_DESC="Server for the BoxBackup on-line backup system" +MAINTAINER="domcox@users.sourceforge.net" +DEPENDS="db libedit openssl perl zlib" +BUILD_DEPENDS="db-dev libedit-dev openssl-dev zlib-dev" +SOURCE="boxbackup" +TARBALL="$SOURCE-$VERSION.tgz" +WEB_SITE="http://www.boxbackup.org/" +WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL" + +# Configuration variables +HOSTNAME=`ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }'` +CONF_DIR="/etc/box" +DATA_DIR="/var/lib/bbstored" +CA_DIR="${CONF_DIR}/ca" +BBUSER="bbstored" + +# Rules to configure and make the package. +compile_rules() +{ + cd $src + ./configure --prefix=/usr $CONFIGURE_ARGS + make +} + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + _pkg=$WOK/$PACKAGE/${SOURCE}-${VERSION}/parcels/boxbackup-${VERSION}-backup-server-linux-gnu + mkdir -p $fs/usr/bin + cp -a $_pkg/bb* $fs/usr/bin + cp -a $_pkg/ra* $fs/usr/bin + mkdir -p $fs/etc/init.d + cp -a stuff/bbstored $fs/etc/init.d +} + + +# Pre and post install commands for Tazpkg. + +pre_install() +{ + # Stop daemon + if [ -e /var/run/bbstored.pid ]; then + /etc/init.d/bbstored stop + fi +} + +post_install() +{ + # adduser BBUSER if needed + if ! grep -q $BBUSER $1/etc/passwd; then + echo -n "Adding user '$BBUSER'..." + echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd + echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow + echo $BBUSER':x:505:' >> $1/etc/group + echo $BBUSER':!::' >> $1/etc/gshadow + status + fi + + # Create config is needed + if [ ! -e $CONF_DIR ]; then + mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR + fi + + if [ ! -e $DATA_DIR/backup ]; then + # Creating backup dir + echo -n "Creating backup directory..." + mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR + status + fi + + if [ ! -e $CONF_DIR/raidfile.conf ]; then + # RAID Setup + echo -n "Disabling deprecated userland RAID..." + /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null + status + chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf + fi + + if [ ! -e $CONF_DIR/bbstored.conf ]; then + # Setting hostname + echo -n "Setting hostname... " + if [ `hostname -f 2>1 > /dev/null;echo $?` -eq 0 ]; then + HOSTNAME=`hostname -f` + fi + if [ -z $HOSTNAME ]; then + HOSTNAME="127.0.0.1" + fi + echo $HOSTNAME + + # Setting up the CA environment + echo -n "Creating certificates..." + /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null + status + + # Generate server certificate request + echo -n "Generate server certificate request..." + bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null + status + + # Sign the server certificate + echo -n "Sign the server certificate..." + openssl x509 -req -sha1 -extensions usr_crt \ + -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \ + -CA $CA_DIR/roots/serverCA.pem \ + -CAkey $CA_DIR/keys/serverRootKey.pem \ + -out $CA_DIR/servers/${HOSTNAME}-cert.pem \ + -days 5000 2>1 > /dev/null + status + + # Preparing the server certificates + echo -n "Installing server certificate..." + cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER + status + echo -n "Installing client certificate..." + cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER + status + + # Securing $CONF_DIR + chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored* + fi + + if [ -e $CA_DIR ]; then + # Warning + echo + echo "IMPORTANT NOTE:" + echo "--------------" + echo "The certificate authority directory $CA_DIR is intended to be" + echo "moved to another system. It should not be kept on the backup server" + echo "to limit the impact of a server compromise." + fi +} + +# Pre and post remove commands for Tazpkg + +pre_remove() +{ + /etc/init.d/bbstored stop +} + +post_remove() +{ + if grep -q $BBUSER $1/etc/passwd; then + echo -n "Removing $BBUSER user..." + deluser bbstored + status + fi + # Delete data + if [ -e $DATA_DIR ]; then + echo -n "Removing all backup data..." + rm -r $DATA_DIR + status + fi + # Delete bbstored conf files + if [ -e $CONF_DIR/bbstored.conf ]; then + echo -n "Removing config files..." + rm -rf $CONF_DIR/bbstored + rm -f $CONF_DIR/raidfile.conf + rm -f $CONF_DIR/bbstored.conf + status + fi + # Delete certificates + if [ -e $CA_DIR ]; then + echo -n "Removing certificates..." + rm -r $CA_DIR + status + fi + # Delete $CONF_DIR (if empty) + if [ `ls $CONF_DIR | wc -l` -eq 0 ]; then + echo -n "Removing $CONF_DIR..." + rm -r $CONF_DIR + status + fi + # Delete PID, sock files + rm -f /var/run/bbstored.* +} \ No newline at end of file diff -r d5be027602dd -r 14003687d2b8 boxbackup-server/stuff/bbstored --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxbackup-server/stuff/bbstored Tue Sep 09 22:18:22 2008 +0200 @@ -0,0 +1,55 @@ +#!/bin/sh +# /etc/init.d/bbstored: Start, stop and restart bbstored deamon on SliTaz, at boot +# time or with the command line. +# +# To start daemon at boot time, just put the right name in the $RUN_DAEMONS +# variable of /etc/rcS.conf and configure options with /etc/daemons.conf. +# +. /etc/init.d/rc.functions +. /etc/daemons.conf + +NAME=BBstored +DESC="BoxBackup server deamon" +DAEMON=/usr/bin/bbstored +OPTIONS=$BBSTORED_OPTIONS +PIDFILE=/var/run/bbstored.pid + +case "$1" in + start) + if [ -f $PIDFILE ] ; then + echo "$NAME already running." + exit 1 + fi + echo -n "Starting $DESC: $NAME... " + $DAEMON $OPTIONS > /dev/null + status + ;; + stop) + if [ ! -f $PIDFILE ] ; then + echo "$NAME is not running." + exit 1 + fi + echo -n "Stopping $DESC: $NAME... " + kill `cat $PIDFILE` + status + ;; + restart) + if [ ! -f $PIDFILE ] ; then + echo "$NAME is not running." + exit 1 + fi + echo -n "Restarting $DESC: $NAME... " + kill `cat $PIDFILE` + sleep 2 + $DAEMON $OPTIONS > /dev/null + status + ;; + *) + echo "" + echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]" + echo "" + exit 1 + ;; +esac + +exit 0