From owner-freebsd-questions Tue Jul 23 22:22:10 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E545D37B400 for ; Tue, 23 Jul 2002 22:22:03 -0700 (PDT) Received: from jeeves.velosystems.net (wsip68-15-85-238.oc.oc.cox.net [68.15.85.238]) by mx1.FreeBSD.org (Postfix) with ESMTP id 533E743E42 for ; Tue, 23 Jul 2002 22:22:03 -0700 (PDT) (envelope-from steve@velosystems.net) Received: from localhost (localhost.velosystems.net [127.0.0.1]) by jeeves.velosystems.net (Postfix) with ESMTP id AB17BA78D; Tue, 23 Jul 2002 22:22:02 -0700 (PDT) Received: from velosystems.net (daemon.velosystems.net [192.168.1.11]) by jeeves.velosystems.net (Postfix) with SMTP id 07C00A6B7; Tue, 23 Jul 2002 22:22:00 -0700 (PDT) Date: Tue, 23 Jul 2002 22:21:59 -0700 From: Steve Wingate To: Michelle Weeks Cc: freebsd-questions@freebsd.org Subject: Re: Backup Scripts Message-Id: <20020723222159.0ad98bfd.steve@velosystems.net> In-Reply-To: <7947A24A-9EB7-11D6-BE51-00039368B8EC@mindspring.com> References: <7947A24A-9EB7-11D6-BE51-00039368B8EC@mindspring.com> Organization: Velosystems X-Mailer: Sylpheed version 0.8.0 (GTK+ 1.2.10; i386-portbld-freebsd4.6) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS perl-11 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 23 Jul 2002 20:43:10 -0700 Michelle Weeks wrote: //////////////////////////////// >I am new to scripting and am trying to use the below script I found to >run backups of our FreeBSD 4.5 server, but I keep getting the error: > >Level-backup.sh Backup Tue Jul 23 21:04:22 PDT 2002 >Error: Level-backup.sh unknown > >Since I am new at this, I am probably missing something very obvious. >I would greatly appreciate any help or advice as to where I can find >more info. on creating backup scripts for FreeBSD. > > >Here is the script I am using: > > ># Variables >EMAILTO=backup >DESTFILE=/dev/nrsa0 >BACKUPFILES="/var /usr/home" >BACKUPDIR=${HOME}/backup >LEVEL=${0} > ># Load backup functions >cd ${BACKUPDIR} >. backup-functions > ># Do the backup >tar_backup > ># Test the backup for errors >tar_verify > ># Email the backup report >mail_report > ># Done >exit > >and here is the .backup-functions file for the shell script: > ># Variables >L0DATESTAMP="${BACKUPDIR}/.level0_datestamp" >NOW=`date` > ># tar_backup function: does the archiving >tar_backup () >{ > echo "Level-${LEVEL} Backup ${NOW}" > if [ "${LEVEL}" = "0" ]; then > # make Level-0 datestamp > echo ${NOW} > ${L0DATESTAMP} > # Level-0 backup > tar --create --verbose \ > --file ${DESTFILE} \ > --blocking-factor 126 \ > --label "Level-${LEVEL} Backup ${NOW}" \ > ${BACKUPFILES} > elif [ "${LEVEL}" = "1" ]; then > # get last Level-0 datestamp > LAST=`cat ${L0DATESTAMP}` > # Level-1 backup > tar --create --verbose \ > --file ${DESTFILE} \ > --blocking-factor 126 \ > --after-date "${LAST}" \ > --label "Level-${LEVEL} Backup from ${LAST} to ${NOW}" \ > ${BACKUPFILES} > else > # Backup level error > echo "Error: Level-${LEVEL} unknown" > exit > fi > echo "Level-${LEVEL} Backup END" >} > ># tar_verify function: test the archive for errors >tar_verify () >{ > echo "Level-${LEVEL} Backup Verify ${NOW}" > # Backup verify test > tar --list --verbose \ > --file ${DESTFILE} \ > --blocking-factor 126 > echo "Level-${LEVEL} Backup Verify END" >} > ># mail_report function: sends backup report >mail_report () >{ > # Email backup report > mail -s "Level-${LEVEL} Backup" "${EMAILTO}" << EOF > >########################################################### >Level-${LEVEL} Backup >########################################################### > >Host: ${HOSTNAME} >Files: ${BACKUPFILES} > >Destination: ${DESTFILE} > >########################################################### >Started: ${NOW} >Completed: `date` >########################################################### > >EOF >} > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-questions" in the body of the message //////////////////////////////// My shell scripting skills are next to non-existent but I think I see a problem with your variables at the beginning, specifically: LEVEL=${0} You're setting a variable to a variable but never defining the absolute value. It seems to me the equivalent of saying: "my name is my name is my name is....infinity" Trying changing "LEVEL=${0}" to "LEVEL=0" and running it again, just for kicks. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message