#! /bin/sh # backup shell script # arguments are list of files to backup # creates sub-directory ./bak/ # copies given files to that subdirectory, # and then compresses them in background. if [ "-h" = "$1" -o "-help" = "$1" ] then echo "Usage: $0 [ ]" echo " Copies the list files to a subdirectory, and compresses them." echo " The subdirectories name is based on the current time and date." echo " Default is to copy all files in the current directory" echo echo " Example:" echo " csh> touch fred; backup fred; ls -R bak;" echo " Thu_Jan_14_15:01:55_CST_1993" echo echo " bak/Thu_Jan_14_15:01:55_CST_1993:" echo " fred" echo exit 0 fi d=`date | sed "s/ /_/g"` f=$* if [ -z "$f" ] then f=* fi if [ -f bak ] then mv bak bak.orig fi if [ ! -d bak ] then mkdir bak fi mkdir bak/$d cp $f bak/$d echo $d gzip bak/$d/* & # compress bak/$d/* &