Listing 3 sshbkp-receiver
#! /bin/sh
# sshbkp-receiver - receive backup on standard input and save to file
# Copyright (C) 2001 Ed Cashin
#
me=sshbkp-receiver
bkpdir=/usr/local/backup
now=`date +%Y%m%d-%H%M%S`
read title
# --------- title must be less than 128 characters long.
# only numbers, digits, underscores, and dashes allowed in title.
#
title_len=`printf $title | wc -c`
if [ `expr $title_len '<' 128` != 1 ] \
|| echo $title | grep '[^-_0-9a-zA-Z]' > /dev/null 2>&1; then
echo $me Error: bad title for backup 1>&2
exit 1
fi
if [ ! -d $bkpdir ] || [ ! -w $bkpdir ]; then
echo $me Error: cannot write to $bkpdir 1>&2
exit 1
fi
file=$bkpdir/$title-$now
gzip > $file.gz || {
echo "$me Error: writing backup to file ($file.gz)" 1>&2
exit 1
}
|