Renamed 'tbku' to 'tbku.sh'.
1 parent 4d3eaeb commit 3cb30f4df899abb02744e580b6fe28fec7485aa8
@tundra tundra authored on 9 Jun 2012
Showing 2 changed files
View
4
makefile
# Build a release of 'tbku' using 'make'
# $Id: makefile,v 1.104 2012/06/09 18:07:30 tundra Exp $
# $Id: makefile,v 1.105 2012/06/09 18:14:29 tundra Exp $
# Requires a modern 'make' like GNU.
 
# Uncomment One Of The Following For Early Releases
 
# Definitions Relevant To This Program
#####
 
PROGNAME = tbku
PROGMAIN = tbku
PROGMAIN = tbku.sh
 
PROGFILES = ${PROGMAIN} # setup.py # Uncomment this if desired for python modules
PROGDOCS = ${PROGMAIN}.ps
 
View
157
tbku 0 → 100755
#!/bin/sh
# Automated Backup Script For TundraWare Inc. Servers
# Copyright (c) 2004-2008, TundraWare Inc., Des Plaines, IL
# All Rights Reserved.
# For Updates See: http://www.tundraware.com/Software/tbku
# $Id: tbku,v 1.1 2012/06/09 18:14:29 tundra Exp $
 
 
#####
# Things User May Want To Change
#####
 
###
# Program Locations
###
 
# Try to figure out where things are on this particular
# system. If you can't, default to FreeBSD settings.
 
DATE=`which date`
LS=`which ls`
SED=`which sed`
TAR=`which tar`
TOUCH=`which touch`
UNAME=`which uname`
 
DATE=${DATE:-"/bin/date"}
LS=${LS:-"/bin/ls"}
SED=${SED:-"/usr/bin/sed"}
TAR=${TAR:-"/usr/bin/tar"}
TOUCH=${TOUCH:-"/usr/bin/touch"}
UNAME=${UNAME:-"/usr/bin/uname"}
 
###
# Default Directories
###
 
# You can override with corresponding environment
# variable or change the default value here.
 
BKUDIR=${TBKUDIR:-"/bku"} # Where to write the backup files
FILESETDIR=${TBKUSETS:-"$HOME/tbku"} # Where to find fileset files
 
###
# Tape Device
###
 
TAPEDEV=${TBKUTAPE:-"/dev/sa0"} # Default to FreeBSD SCSI tape
 
###
# File Naming
###
 
DATETIME=-`${DATE} "+%Y%m%d"` # Datestamp used to uniquely ID backups
MACHINE=`${UNAME} -n`- # Name of the machine we're on
OSTYPE=`${UNAME} -s`- # Operating System Type
OSREV=`${UNAME} -r`- # Operating System Revision Level
HWTYPE=`${UNAME} -p` # Processor Type
 
BKUNAME=${MACHINE}${OSTYPE}${OSREV}${HWTYPE} # Backup base name
BKUNAME=${TBKUNAME:-$BKUNAME} # But the user can override it
 
####
# Automatic Deletion Of Previous Backups
####
 
# Use this with caution!
 
BKUDEL=${TBKUDEL:-"NO"} # Must be "YES" for autodelete
 
 
############## Nothing Below Should Need To Be Changed #############
 
 
ALLSETS="allsets" # Special name to force every backup set to be done
COMMON="auto" # Common name for automated backups
 
#####
# Setup
#####
 
umask 077 # Make sure only owner can read backups
mkdir -p ${BKUDIR} # Make sure the backup directory exists
 
 
#####
# Figure Out Which Backup Sets To Do
#####
 
cd $FILESETDIR
 
if [ $# -ne 0 ]
then
if [ _$1 = _$ALLSETS ]
then
LIST=`${LS} * 2>/dev/null`
else
for arg in $*
do
a=`${LS} *${arg} 2>/dev/null`
LIST=$LIST" $a"
done
fi
 
else
LIST=`${LS} $COMMON* 2>/dev/null`
fi
 
 
#####
# Do The Actual Backups, And Leave Indication Of Start/Stop Times For Each Backup Set
#####
 
 
# If nothing matches / there is nothing to do, tell the user
 
LST=`echo $LIST | ${SED} "s/\ //"` # Get rid of spaces from concatenation above
if [ "_${LST}" = "_" ]
then
echo "tbku: Nothing to do! Exiting ..."
exit
fi
 
 
# Otherwise process each fileset
 
for x in $LIST
do
s=`echo $x | ${SED} "s/.*\.//"` # Get the suffix
 
BASENAME=$BKUNAME-$s
STAMPEDNAME=${BASENAME}${DATETIME}
 
#####
# Distinguish Between Tape And File Backups
#####
 
if [ "_${s}" = "_tape" ]
then
FULLNAME=$TAPEDEV
else
FULLNAME=$BKUDIR/$STAMPEDNAME.tar.gz
fi
 
# Optionally, get rid of previous backups of this fileset
 
if [ _${TBKUDEL} = "_YES" ]
then
rm $BKUDIR/.$BASENAME* $BKUDIR/$BASENAME*
fi
 
echo "Now Doing Backup Set: $s"
${TOUCH} $BKUDIR/.$STAMPEDNAME-begin
${TAR} -cvzT $FILESETDIR/$x -f $FULLNAME >$BKUDIR/$STAMPEDNAME.log 2>&1
${TOUCH} $BKUDIR/.$STAMPEDNAME-end
done