#!/bin/sh
#
# This script creates a backup archive of specified file paths
# and uploads it to an FTP server. It uses the script "pipesplit.pl"
# to split the archive into several chunks, since cannot transfer files
# larger than 2 Gb.
#
# Last change: 2006-10-21 Stefan Tomanek <stefan@pico.ruhr.de>
#                         http://stefans.datenbruch.de/rootserver/

FTPUSER="userid"
FTPPASS="secret"
FTPSRV="backup.example.com"

BNAME="$1"
shift
BPATH="$*"

DATE="$(date +%Y%m%d-%H%M)"

echo "Backup name is »$BNAME«"
echo "Paths to be saved: $BPATH"

PIPESPLIT="pipesplit.pl"
tar cpvj -l $BPATH | $PIPESPLIT "curl -u $FTPUSER:$FTPPASS --upload-file - ftp://$FTPSRV/$BNAME-$DATE-chunk{}.tar.bz2"

