This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Backup script not working properly

I have used a very nice backup script i Linux which i now want to use in 

# for FULL backups
# this backs up the important stuffs listed in ${lists} to ${BKPDIR}
# the lists *should* be in ${BKPDIR} and named <whatever>.lst
# the resulting backups will be <whatever>.<timestamp>.tgz
# notes:
# - assumes ${BKPDIR} is unmounted and has an /etc/fstab entry
# - assumes /boot is unmounted and has an /etc/fstab entry
# - variables in CAPS are ok for you to set... change the other
#   vars if you know what you're doing
# - you can get fancy in the lists... think xargs *wink*, but
#   you can't use thes spanning feature to break up an
#   archive to smaller pieces of arbitrary size
# - follow your security policy when setting perms on ${BKPDIR}
# written by razamatan
# DISCLAIMER: razamatan didn't write this if something goes wrong
BKPDIR=/cygdrive/d/backup	# where the backups go
#BOOT=sys			# list that has /boot
NUMBKPS=4			# how many backups to keep
if [ ! -d ${BKPDIR} ] ; then
    echo ${BKPDIR} is not a valid directory or does not exist
#mount ${BKPDIR}		# i have my backup directory on a seperate 
for list in `ls ${lists}`; do
    type=`basename ${list} .lst`
#    if [ ${type} = ${BOOT} ] ; then mount /boot ; fi
    cat ${list} | xargs tar zlcf \
	${BKPDIR}/${type}.`date +%Y-%m-%d-%H%M`.${ext} > /dev/null 2>&1
#    if [ ${type} = ${BOOT} ] ; then umount /boot ; fi
    for evict in `ls -t ${BKPDIR}/${type}.*.${ext}`; do
        echo ${evict}
	if [ ${num} -le 0 ] ; then rm -f ${evict}
	else num=$((${num}-1)) ; fi
#umount ${BKPDIR}	# and i like to keep it unmounted

All works but for the last for-loop which is responsible for deleting old 
backups such that only NUMBKPS=4 of the last backups are stored.

The problem is in 'if [ ${num} -le 0 ]' and 'else num=$((${num}-1))'. It seems 
like the num-variable can't be used as an integer. Any suggestions how to fix 

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]