Search Text         
Search Tips?
Search By   And   Or   Boolean   Exact Match   TA #
Search In   Whole Doc   Keywords Sort By  
Product   Sub Product  

View Technical Articles (sorted by Product) New/Updated in the last:    7 days      14 days      30 days             
TA # Date Created Date Updated Resolved Issue?   Printer Friendly Version of This TA   Print Article
  E-mail This TA   E-mail Article
116623 01/22/2002 05:12 PM 11/18/2009 09:02 AM
Yes No
UW7/OSR6:Where can I find a simple backup script to backup my server onto a tape on a nightly basis?
Keywords
uw2 unixware2 2.1.0 2.1.1 2.1.2 2.1.3 210 211 212 213 uw7 unixware unixware7 uware 7.0.0 7.0.1 7.1.0 7.1.1 700 701 710 711 sco sco open unix openunix openunix8 ou ou8 8.0.0 simple backup cpio cron rmt ctape1 tape regular 712 7.1.3 713 7.1.3. 714 7.1.4 lkp troubleshooting /dev/tty STDIO -G out of storage medium error full tty osr osr6 openserver openserver6 6.0.0 600 errors
Release
          SCO Open UNIX 8 Release 8.0.0   
          UnixWare 7 Release 7.0.0, 7.0.1, 7.1.0., 7.1.1, 7.1.2, 7.1.3, 7.1.4 
          SCO OpenServer Release 6.0.0 
          UnixWare Application Server Release 2.1.0, 2.1.1, 2.1.2, 2.1.3 
          UnixWare Personal Edition Release 2.1.0, 2.1.1, 2.1.2, 2.1.3 
Problem
          Where can I find a simple backup script to backup my server onto a
          tape on a nightly basis for UnixWare7/OpenServer6?


Solution
          There are many methods of running backups.  Many will be detailed
          in the documentation provided at http://www.sco.com/support/docs.

          However, a simple backup script is provided below.

          Cut the script (shown below).  The script also contains an example
          "cron" entry, so the task can be scheduled and highlight areas to be
          considered when performing a backup, such as unmounting certain
          filesystems and stopping databases that are unable to support a live
          backup.  The example here is for a Progress but could be changed for
          databases such as Oracle, Informix, etc.

          This script serves as an example only, because each customer's
          configuration is different, but will serve as a simple method of
          running a backup.

----- cut here

#!/bin/sh
#
# ident   "@(#) simple.backup"
# comment "@(#) Backup Directories to Tape"
#
# Usage: $0
#
# Typical "root" Cron entry to run the simple.backup
# 30      23      *       *       1-5     /local/sysadm/simple.backup > \
/dev/null 2>&1
#
# This script should be modified to suit your own environment prior to running.
#

PATH=/bin:/usr/bin:/etc:/local/bin
export PATH

DAY=`date '+%a' | tr '[A-Z]' '[a-z]'`
BACKUPLOG=/tmp/backuplog.${DAY}
DEFBACKUPLOG=/tmp/backuplog
MACHINE=`uname -n`
DEFAULT=/etc/default/simple.backup.def
CDROM=`mount | grep cd | awk '{print $3}'`
SSL=/usr/lib/ssl

# OS
case `uname` in
   SCO_SV)
        BACKUP_DEVICE=/dev/rct0
        OS="OpenServer"
        ;;
   UnixWare)
        BACKUP_DEVICE=/dev/rmt/ctape1
        OS="UnixWare"
        ;;
   OpenUNIX)
        BACKUP_DEVICE=/dev/rmt/ctape1
        OS="OU"
        ;;
   *)
        BACKUP_DEVICE=/dev/tape
        OS="Linux"
        ;;
esac
echo $OS

if [ -r ${DEFAULT} ]
then
        . ${DEFAULT}
else
# If the "defaults" file isn't there, then set some sensible values.
        BACKUP_FILES="."
        BACKUP_MAILID="root"
        export BACKUP_DEVICE BACKUP_FILES BACKUP_MAILID
fi

# Exit routine for "simple.backup".
exit_backup() {
# Write message to console.
        echo "\n\r`date`: $1" > /dev/console

# Write message to the backup log.
        echo "`date`: $1" >> $BACKUPLOG

# Write message to the system log.
        logger -it Backup "$1"

# Mail administrator.
        mail -s "Backup (${DAY}) on \"${MACHINE}\" $2" $BACKUP_MAILID <<! \
From the Backup Wizard at `date`:

$1
!
}

# Remove the default backup logfile first. This prevents "backupcheck" sending
# misleading e-mails should this program fail before writing to the backup
# logfile.
rm -f $DEFBACKUPLOG

# Unmount SSL CD (if installed); do this before un-mounting any
# conventionally mounted CDs.
if test -d ${SSL}
then
        /etc/ssl stop
fi

# Unmount any CD Devices or NFS mounted filesystems which may be permanently
# mounted because you may not want to back up these contents.
if test -z "${CDROM}"
then
        :
        # No CDs in the machine, so do nothing.
else
        for i in $CDROM
        do
                umount $i
        done
fi

# Stop NFS.
# --------
case "${OS}" in
   OpenServer)
        if [ -f /etc/rc2.d/S89nfs ]; then
                sh /etc/rc2.d/S89nfs stop >> ${BACKUPLOG} 2>&1
        fi
        ;;
   UnixWare)
        if [ -f /etc/rc3.d/S22nfs ]; then
                sh /etc/rc3.d/S22nfs stop >> ${BACKUPLOG} 2>&1
        fi
        ;;
   OU)
        if [ -f /etc/rc3.d/S22nfs ]; then
                sh /etc/rc3.d/S22nfs stop >> ${BACKUPLOG} 2>&1
        fi
        ;;
   Linux)
        if [ -f /etc/rc.d/rc3.d/S40nfs ]; then
                sh /etc/rc.d/rc3.d/S40nfs stop >> ${BACKUPLOG} 2>&1
        fi
        ;;
esac

# Shutdown any Database servers that need to have closed files before a backup
# is made.  In this example, Progress
if test -x /etc/rc2.d/S95progress
then
        /etc/rc2.d/S95progress stop
        sleep 5
fi

# Now run the actual backup program. Note that standard error has to be
# re-directed for "cpio".

echo "`date`: ** System Backup started on \"${BACKUP_DEVICE}\" **" > $BACKUPLOG
echo "\n\r`date`: ** System Backup started on \"${BACKUP_DEVICE}\" **" >
/dev/console

# 
NOTE:
      Some Linux flavours do not support the "c" flag.

cd /

# Uncomment the cpio option of your choice : -B for standard blocking or -C 32768 
(preferred)

#find ${BACKUP_FILES} -depth -print | cpio -ocvB -O $BACKUP_DEVICE >> \
$BACKUPLOG 2>&1

#find ${BACKUP_FILES} -depth -print | cpio -ocv -C32768 -O $BACKUP_DEVICE >> \
$BACKUPLOG 2>&1
RESULT=$? export RESULT

if [ ${RESULT} = 0 ];
then
        exit_backup "** System Backup on \"$MACHINE\" to ${BACKUP_DEVICE} \
completed O.K. **" \
                        "O.K."
else
        exit_backup "** System Backup on \"$MACHINE\" to ${BACKUP_DEVICE} \
has F A I L E D **" \
                        "FAILED!"
fi

# Link the separate daily copy of the backup log to the standard name
# so that the "backupcheck" program finds it O.K.
#
chmod 644 $BACKUPLOG
ln $BACKUPLOG $DEFBACKUPLOG

# Re-start Database servers
if test -x /etc/rc2.d/S95progress
then
        /etc/rc2.d/S95progress start
        sleep 1
fi

# Start NFS.
# ---------
case "${OS}" in
   OpenServer)
        if [ -f /etc/rc2.d/S89nfs ]; then
                sh /etc/rc2.d/S89nfs start >> ${BACKUPLOG} 2>&1
        fi
        ;;
   UnixWare)
        if [ -f /etc/rc3.d/S22nfs ]; then
                sh /etc/rc3.d/S22nfs start >> ${BACKUPLOG} 2>&1
        fi
        ;;
   OU)
        if [ -f /etc/rc3.d/S22nfs ]; then
                sh /etc/rc3.d/S22nfs start >> ${BACKUPLOG} 2>&1
        fi
        ;;
   Linux)
        if [ -f /etc/rc.d/rc3.d/S40nfs ]; then
                sh /etc/rc.d/rc3.d/S40nfs start >> ${BACKUPLOG} 2>&1
        fi
        ;;
esac

# Re-mount any CD devices or NFS filesystems which were previously un-mounted.
if test -z "${CDROM}"
then
        :
else
        for i in $CDROM
        do
            case "${OS}" in
            OpenServer)
                mount -f HS -o relax,lower -r $i
                ;;
            UnixWare)
                mount -F cdfs -r /dev/cdrom/cdrom1 /CD-ROM_1
                ;;
            OU)
                mount /dev/cdrom/cdrom1 /CD-ROM_1
                ;;
            esac
        done
fi

# Re-mount SSL CD (if installed).
if test -d ${SSL}
then
        /etc/ssl start
fi

----- cut here

          If you wish to run the same script on different servers, you can
          also introduce the file:

                /etc/defaults/simple.backup.def

          An example of this is shown below, although it is not necessary for
          this file to exist for the script to run.

----- cut here
:
#
# ident   "@(#) /etc/default/simple.backup"
# comment "@(#) Details of what to backup"
#
# Usage:        Called from simple.backup script
#
# THE BACKUP_MAILID IS THE PERSON WHO CHANGES THE BACKUP TAPES ON SITE!
#
BACKUP_DEVICE=/dev/rStp0
BACKUP_FILES="."
BACKUP_MAILID="root"

export BACKUP_DEVICE BACKUP_FILES BACKUP_MAILID

----- cut here

          When it comes to restoring data from the tape, here are some simple
          steps to follow:

          
NOTE:
      How to restore from a simple backup tape ...

          1. Does the tape need cleaning?

             - If Yes, clean the tape 3 times before you start to ensure data
               integrity.

          2. Can we see the tape okay?

               tape xstatus

          3. Are the files I want to restore on the tape?

             vi $BACKUPLOG files first to ensure you have the correct tape
             in the drive.

             You may wish to recover the first couple of files on the tape to
             test the tape's integrity.

          4. Where do I restore the files to?

             You may not want to overwrite what is currently there immediately
             so do the following:

                 mkdir /tmp/recovered
                 cd /tmp/recovered

          5. How do I restore the files?

                 cpio -icdvBm -I/dev/rStp0 "u1/.../.../*" "more files"

             If you use the "q" parameter in the cpio command, you can specify
             one file. Once the file has been restored, the cpio command won't
             search the remainder of the tape.

             If the files have a leading slash on the tape, you mustk use
             the -A parameter to suppress the leading slash, otherwise it
             will overwrite files in the top directory.

             Add the A parameter to end of the command (for example, -icdvBmA).

             If I wish to exclude rather than just include then use the ! 
             pattern, eg:

                 "!/u1*"

             would restore everything 'excluding' /u1.

             Please note that only ONE exclude is permitted.

             Please note that the exclude will not work in the bash shell as it
             will report that the event hasn't occured.  It can be used in sh
             and ksh shells.

          6. If you have restored the files into /tmp/recovered, you will need
             to put the files back into the appropriate directory:

                 cd /tmp/recovered
                 find . -print | cpio -pdumv {destination}

             As an example:

                 cd /tmp/recovered/u1/fred.smith/work
                 find . -print | cpio -pdumv /u1/fred.smith/work

NOTE:
          If you have installed LKP you will need to explicity
          define the filesystems you want mounted otherwise "find" may
          cycle in an infinite loop as it recurivesly mounts the LKP
          filesystems, as:

          cd / ; find / /stand /data -mount -depth -print | cpio ...

NOTE:
          TROUBLESHOOTING:
          ---------------
          1.  I'm seeing the error message:

          'UX:cpio:ERROR: Cannot open "/dev/tty"

          appearing in my logfiles and the backup's reporting as failed.

          It's likely that the backup tape has been filled and it's requesting
          a new medium.  Since, within a "cron", no specific "tty" is assigned
          "cpio" is unable to write the message.

          It is suggested to include "-G STDIO" within the "cpio" backup line,
          as:

          find ${BACKUP_FILES} -depth -print | cpio -ocvB -O $BACKUP_DEVICE >>\
          $BACKUPLOG 2>&1     

          to:

          find ${BACKUP_FILES} -depth -print | cpio -ocvB -G STDIO \
          -O $BACKUP_DEVICE >> $BACKUPLOG 2>&1   


          2.  The cpio/tar process has hung or the tape or hardware has failed 
              and the process is 'looping', ie. I am unable to kill the 
              process.

              Running rtpm gives the error "rtpm:ftw() failed".

              The hung process can be cleared by a reboot of the server.

              It is advisable to ensure that the Controller and Tape itself is
              using the latest driver and firmware release.  It is also 
              recommended to check the tape drive temperature and consider 
              replacing the tape media.
                            

          3.  I am unable to access the tape, as I get:

              /dev/rmt/ctape1 value too large 

              Check that there isn't a 2GB file present in /dev/rmt/ctape1

              If there is, remove the file and on the next reboot the correct
              tape device will be created.
 

          4.  I am getting in syslog and on the console:

              "WARNING: Tape Driver: HA x TC x LU x - CHECK CONDITION:"

              "WARNING: Tape driver: Block length mismatch (overlength)."

              "WARNING: Tape driver: Block length mismatch."

              "WARNING: Tape driver: Reserve tape failed to restore."

              and cpio responds with:

              UX: cpio: HALT: cannot write to device

              implies either a hardware fault with your tape, controller or
              lead or with the tape media or the block speed in which the
              data was written or corrupted media.

              
          5.  I am getting the following errors:

               "Permission denied" "WARNING: Reserved tape failed to release!"

               Check the tape is not set to read/only.

Related Articles
•  Increasing pseudo-ttys on UnixWare 7 fails to create pts (regular pseudo-tty) devices.
•  My UnixWare system is not switching to or from daylight saving time on the correct date.
•  I can't print 8-bit ASCII characters to my HP LaserJet.
•  Mail from cron jobs does not put the subject line in the header of the email.
Back to Search ResultsBack to Search Results