Visit Our UNIX and Linux User Community


cpio backup to a remote device..


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cpio backup to a remote device..
# 1  
Old 07-17-2002
cpio backup to a remote device..

Hi,

Needing to perform a backup of one system to the tape unit on another system. Why, well because the local tape device is stuffed and I desparately need to have a backup completed successfully sooner rather than not at all.

My question is how do I set the below code to allow me to perform the cpio command to write to the everest_backup: server's /dev/nrStp0 device?

Code:
:
state=`cat /etc/MSTATE`; if [ $state != "master" ]; then exit 0;fi
umask 0
DIRECTORY=/u/backup
export DIRECTORY
DEVICE1=everest_backup:/dev/rStp0
DEVICE2=everest_backup:/dev/nrStp0
CPIOCMD="cpio -ovcB > $DEVICE2"
FILE=nite`date '+%d'`
STATUS="OK"
export FILE

## **** Comment the below two(2) lines ONLY when testing ****
#/u/everest/cron/rcp_trans_logs_daily.sh
#/u1/everestnz/cron/rcp_trans_logs_daily.sh

# If a different directory or file name is required for the backup,
# changed the above lines only.
# Check for the existance of backup directory.
# If it doesn't exist, create it. The logfile will be created automatically.

exit_print ()
{
        if [ $* -gt 0 ]
          then
            STATUS=FAULTY
        fi
#       echo "Exit Code: $*" >> $LOGFILE

        cat $LOGFILE | \
        mail -s"$STATUS backup of TVL(EVEREST) on Everest-backup." ops@somedomain.com.au
        exit 0
}

if [ ! -d $DIRECTORY ]
then
        mkdir $DIRECTORY
fi

LOGFILE=$DIRECTORY/$FILE
LOGFILE_DETAIL=$DIRECTORY/"$FILE"_DETAIL

# Remove all core and enc files from directories being backed up.
# find /usr/acct \( -name core -o -name '*.enc' \) -print | xargs /bin/rm -f &
# Remove all core from system.
# The following command has been # out as it took over 1&half hours to complete

# run from cron every week instead
#find / -name core -print | xargs /bin/rm -f

# Remove enc files from directories being backed up.

echo "" > $LOGFILE
echo "" > $LOGFILE_DETAIL
echo "Backup of everest commenced  "`date` >> $LOGFILE
echo "" >> $LOGFILE

# Retension tape
echo "** Backup Start using cpio command:"
echo "**       '"$CPIOCMD"'."
echo "** Rewinding Tape Device: "$DEVICE1
tape rewind $DEVICE1
echo "** Rewinding Tape Device: "$DEVICE1
tape rewind $DEVICE1
echo "** Sleeping (20)"
sleep 20
echo "** Rewinding Tape Device: "$DEVICE1
tape rewind $DEVICE1
ERROR="$?"
echo "** Error Result of Rewind: "$ERROR
case $ERROR in
  0) ;;
  *) echo " " >> $LOGFILE
     echo "**** WARNING ****" >> $LOGFILE
     echo "Cannot retension tape. Backup Aborted." >> $LOGFILE
     echo "    Error Status = $ERROR" >> $LOGFILE
     exit_print $ERROR ;;
esac

cd /
marker=0
errcount=0

# "/x1" used for testing.
#for shit in "/x1"
#for shit in "/" "/stand" "/u" "/u1" "/u2"
#for shit in "/" "/stand" "/u" "/u1" "/u2" "/x1"

for shit in "/x1"
  do
    echo "**** Changing To Directory: "$shit
    cd $shit
    echo "**** File marker $marker filesystem "$shit
    echo "File marker $marker filesystem $shit" >> $LOGFILE
    date >> $LOGFILE

    #ps -ef >> $LOGFILE_DETAIL
    #fuser $shit >> $LOGFILE_DETAIL

    echo " " >> $LOGFILE_DETAIL
    if  [ `date +'%u'` -ge 1 -a `date +'%u'` -le 5 ]
      then
        #incremental backup mon to fri

        echo "**** Backup of "$shit" Commenced. ( "`date '+%R'`" )"
        find . -mtime -14 -mount -depth -print | \
          $CPIOCMD \
            2>> $LOGFILE_DETAIL
        echo "**** Backup of "$shit" Completed.( "$?" )"

        ## - Revert to Full-Backups as of 19/04/02 - requested by Anish (TVL)
        ##  find . -mount -depth -print |cpio -ovcB >$DEVICE1 \
        ##   2>> $LOGFILE_DETAIL

        ##  find . -mount -depth -print | \
        ##  cpio -ovcC32768 | dd of=$DEVICE1 conv=bmode bs=32k \
        ##    2>> $LOGFILE_DETAIL

      else
        #full backup sat/sun
        ##find . -mount -depth -print | \
        ##  cpio -ovcB >$DEVICE1 2>> $LOGFILE_DETAIL
        find . -mount -depth -print | \
          cpio -ovcC32768 | dd of=$DEVICE1 conv=bmode bs=32k \
            2>> $LOGFILE_DETAIL

    fi
  ERROR="$?"
  marker=`expr $marker + 1`
  errcount=`expr $errcount + $ERROR`
done

ERROR=$errcount
echo " " >> $LOGFILE

# Test for success of backup.
case $ERROR in
        0) echo "Backup successful .... Phew!" >> $LOGFILE ;;
        *) echo "** WARNING ** Backup unsuccessful ended "`date` >> $LOGFILE
        case $ERROR in
        2)  echo " PROBLEM WITH TAPE DRIVE" >> $LOGFILE
            exit_print $ERROR ;;
        4)  echo " INTERRUPTED SYSTEM CALL" >> $LOGFILE
            exit_print $ERROR ;;
        5)  echo "          I/O ERROR" >> $LOGFILE
            exit_print $ERROR ;;
        6)  echo " NO SUCH DEVICE1 OR ADDRESS" >> $LOGFILE
            exit_print $ERROR ;;
        7)  echo " ARGUMENT LIST TOO LONG" >> $LOGFILE
            exit_print $ERROR ;;
        11) echo " NO MORE PROCESSES" >> $LOGFILE
            exit_print $ERROR ;;
        12) echo " NOT ENOUGH SPACE" >> $LOGFILE
            exit_print $ERROR ;;
        13) echo " PERMISSION DENIED" >> $LOGFILE
            exit_print $ERROR ;;
        28) echo " NO SPACE ON DEVICE1" >> $LOGFILE
            exit_print $ERROR ;;
        *)  echo "    ** Aborting **" >> $LOGFILE
            echo "    Error Status = $ERROR"  >> $LOGFILE
            exit_print $ERROR ;;
        esac ;;
esac

echo "  " >> $LOGFILE
echo " End Time:     "`date '+%H:%M:%S'` >> $LOGFILE
echo " " >> $LOGFILE

echo "** Getting Status of  Tape Device: "$DEVICE1
tape status $DEVICE1 >> $LOGFILE
echo "** Rewinding Tape Device: "$DEVICE1
tape rewind $DEVICE1
echo "** Unloading Tape Device: "$DEVICE1
tape unload $DEVICE1
echo " Rewind completed:     "`date '+%H:%M:%S'` >> $LOGFILE
echo " " >> $LOGFILE
# Test for successful read of tape. If not successful, end script.
echo " " >> $LOGFILE
echo "BACKUP OF BOOKING ENGINE  COMPLETED AT "`date` >> $LOGFILE
exit_print 0

# 2  
Old 08-15-2002
have you updated the .rhosts file on both servers ?
# 3  
Old 08-15-2002
Yep, both updated.

Could I be missing something in the script??
# 4  
Old 08-15-2002
First - look to insure you can 'go both ways'

On system everest (the one with the tape drive) do a
% rsh systemX uptime

as the user who will be running the script. Then go from systemX (the one to be backed up) to system Everest.
% rsh everest_backup uptime

If you get a response both ways of the output of the uptime command (or one of your favorites) then the next problem is permissions on the tape drive. If you get permission denied, then there is still a problem with trust between the servers. That is usually the problem - check your /etc/hosts.equiv files or appropriate rhost files for the user and servers.

It's possible that a regular user can't backup to the tape drive. Sign in as the user that will be running the job on the client. See if you can manually cpio to the tape drive on everest.

If this all works, then run the script manually. If it works - run in cron.

Post back results for all test.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #341
Difficulty: Easy
Steve Jobs invented the first Apple Computer.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Cpio - input files (from list) are stored in different order inside cpio archive - why?

Due to budget constraints I have to reinvent an Enterprise backup system in a SPARC (sun4v) Solaris estate (10 & 11). (yep - reinvent wheel, fun but time consuming. Is this wise?! :confused: ) For each filesystem of interest, to try to capture a 'catalog' at the front of each cpio archive (for... (1 Reply)
Discussion started by: am115998
1 Replies

2. AIX

Cpio: copy failed - No space left on device when I use rpm

Hello, I want to install GCC gcc-4.8.1-2.src.rpm for AIX 6.1 when I lance my command rpm -i gcc-4.8.1-2.src.rpm I have this error unpacking of archive failed on file gcc-4.8.1.tar.bz2: cpio: copy failed - No space left on device I checked the free space and I am surpise becouse I have... (7 Replies)
Discussion started by: tatab355
7 Replies

3. AIX

Backup to a remote tape device. Is it possible?

Hi all The situation is as follows: We need to take an mksysb image from an AIX 6.1 server. From some reason (irrelevant to this discussion) this server does not have access to a local CD-ROM or a tape drive. We do have another server with AIX 6.1 (but different technology level) which got access... (1 Reply)
Discussion started by: abohmeed
1 Replies

4. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

5. UNIX for Dummies Questions & Answers

Remote Tape Backup Using cpio

Hi all, I've got two HP machines running HP-UX 11.31 and would like to remotely backup one server onto another server's tape unit using the cpio command. The two servers use a secured communication channel, i.e ssh. Kindly help, Koketso (1 Reply)
Discussion started by: Koketso
1 Replies

6. SCO

cpio Backup and restore to spare server fails

Our company purchased a spare HP ML350 server - identical to current one in use to act as minimal downtime replacement should the inevitable happen. After install of OS 5.0.7 and restore of cpiobackup I get this message: -: Syntax error: Hostname= $inexpected The SCO licence policy... (4 Replies)
Discussion started by: moondogi
4 Replies

7. UNIX for Advanced & Expert Users

extract cpio backup on tape

Hi, I was wondering, If I take a backup using cpio to tape from UNIX, can I extract data on windows box using cpio for windows? Anybody ever do this? Thanks. (1 Reply)
Discussion started by: yonez
1 Replies

8. SCO

CPIO Backup End of Media

I'm having problems getting backups working on SCO OpenServer 5.7. using the following command: find / -depth -print | cpio -ocvB -O /dev/rct0 some files are backed up then the following error is reported: Reached end of medium on output. Device /dev/rct0: Change to part 2 and... (6 Replies)
Discussion started by: RMA1
6 Replies

9. UNIX for Dummies Questions & Answers

backup with CPIO

Hi All, I have a tape backup(DDS2) with cpio. I want to restore just some directory from this device but I do not know the command ?? other question what is the best cpio command to take more than 8 GB data ? thanks Alice (1 Reply)
Discussion started by: alisevA3
1 Replies

10. UNIX for Dummies Questions & Answers

backup listing(cpio)

Hi i am using HPUX and i want to know wht is the command to see the listing from the tape device.. i have taken the backup using cpio -ocvB>/dev/rmt/0m while seeing the listing using cpio -itvB</dev/rmt/0m it is not showing the listing giving message -c option sd be there if i put -c... (1 Reply)
Discussion started by: Prafulla
1 Replies

Featured Tech Videos