Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Fredrik Persson Subject: Backup script not working properly Date: Wed, 13 Oct 2004 10:34:05 +0000 (UTC) Lines: 56 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 129.16.43.138 (Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)) X-IsSubscribed: yes I have used a very nice backup script i Linux which i now want to use in cygwin. -------------------------------------------------------------------------- #!/bin/sh # for FULL backups # this backs up the important stuffs listed in ${lists} to ${BKPDIR} # the lists *should* be in ${BKPDIR} and named .lst # the resulting backups will be ..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 fi #mount ${BKPDIR} # i have my backup directory on a seperate partition lists=${BKPDIR}/*.lst ext=tgz 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 num=${NUMBKPS} for evict in `ls -t ${BKPDIR}/${type}.*.${ext}`; do echo ${evict} if [ ${num} -le 0 ] ; then rm -f ${evict} else num=$((${num}-1)) ; fi done done #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 this??? -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/