#!/bin/sh # # Backup the files $1, $2, ... to the ./OLD directory with appended # date. # # Usage: backup foo boo goo # # Backup the files 'foo', 'boo', and 'goo' in the # ./OLD directory. Append the date and version suffix # to the base filename to handle multiple versions # FILES=$* SUFFIXES="a b c d e f g h i j k l m n o p q r s t u v w x y" END="z" SUFFIXES=${SUFFIXES}" "$END DATE=`date '+%m.%d.%y'` if [ ! -d OLD ]; then echo "./OLD does not exist. Making ./OLD now." mkdir OLD chmod 755 OLD fi for F in $FILES do B="./OLD/$F.$DATE" if test -f $F then for S in $SUFFIXES do if test -f ${B}$END then echo "You have already created 27 backup versions for the same day." echo "I can't make any more for you." break fi if test -f ${B}$S then continue else echo "Copying $F to ${B}$S" cp $F ${B}$S break fi done else echo "The file $F does not exist." fi done