Date: Thu, 25 Jul 2002 09:55:35 -0700 From: Michelle Weeks <tristan11@mindspring.com> To: freebsd-questions@freebsd.org Subject: Re: Backup Scripts Message-ID: <5703127A-9FEF-11D6-A5A4-00039368B8EC@mindspring.com>
next in thread | raw e-mail | index | archive | help
--Apple-Mail-1--83187897 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed The below script that I was having problems with is working for me now thanks to Steve's suggestion; however when I changed the script to do a Level 1 tar archive, I get the following output after tar_verify: Level-1 Backup END Level-1 Backup Verify Wed Jul 24 15:38:47 PDT 2002 tar: echo not found in archive tar: Level-1 Backup Verify END not found in archive I did a tar tv of the tape and saw that the backup was completed, but am not sure why I get the above message. Also after running the script, 2 files are created on the tape. One of which contains the backup archive and the other which is empty - at least var t doesn't print anything out. Shouldn't the tar command just create one file? Here is the script I am using: #! /bin/sh # Variables EMAILTO=backup DESTFILE=/dev/nrsa0 BACKUPFILES="/var /usr/home" BACKUPDIR=${HOME}/backup LEVEL=1 # 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} \ --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} \ --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} \ 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 } --Apple-Mail-1--83187897 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII The below script that I was having problems with is working for me now thanks to Steve's suggestion; however when I changed the script to do a Level 1 tar archive, I get the following output after tar_verify: Level-1 Backup END Level-1 Backup Verify Wed Jul 24 15:38:47 PDT 2002 tar: echo not found in archive tar: Level-1 Backup Verify END not found in archive I did a tar tv of the tape and saw that the backup was completed, but am not sure why I get the above message. Also after running the script, 2 files are created on the tape. One of which contains the backup archive and the other which is empty - at least var t doesn't print anything out. Shouldn't the tar command just create one file? <color><param>5454,0000,0000</param>Here is the script I am using: #! /bin/sh # Variables EMAILTO=backup DESTFILE=/dev/nrsa0 BACKUPFILES="/var /usr/home" BACKUPDIR=${HOME}/backup LEVEL=1 # 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} \ --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} \ --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} \ 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 } </color> --Apple-Mail-1--83187897-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5703127A-9FEF-11D6-A5A4-00039368B8EC>