Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote Tape BackUp to.... - is this possible?

Status
Not open for further replies.

franksoprano

Technical User
Apr 13, 2002
249
US
I have a tricky question for you guru's, this may be a piece of cake for you but here goes:

I am at home infront of my RS6K, I want do not have a tape drive attached to my system and would like to do a mksysb to RS6K at work that has a tape drive attached, now that should be the easy part....

Here is the hard part, after the mksysb is done, how would I go about restoring that mksysb to my system at home from the remote server with the tape drive??

Is this possible? Any suggestions?

Thanks! :)
 
I have a T line connection between both boxes, connection is not a problem...
 
To do a straight backup to a remote machine use

tar -b1 -cf - . | rsh REMOTEHOST "dd ibs=512 obs=1024 of=/dev/TAPEDEVICE"

If you want to make a complete bootable system backup with mksysb, this is not completely possible. There is a remote mksysb script, but it creates the bootimage on the remote host. Usually this works.

This was written for AIX 3.*
so you may have to tinker with it.

#!/bin/ksh
#######################################################################
# rmksysb #
#######################################################################
# #
# Description: #
# creates a bootable mksysb backup of a remote system running #
# AIX 3.x or lists the Table of Contents of the current tape #
# #
# Usage: #
# ./rmksysb $1 [$2] #
# $1 - remote host to be backed up #
# $2 - optional: local tape device (default: rmt0) #
# or: #
# ./rmksysb -l [$2] #
# to list Table of Contents saveset on tape in $2 #
# (only useful on tapes created by rmksysb) #
# #
# Output: #
# a bootable mksysb of the remote system #
# or a listing of the TOC saveset on the current tape #
# #
# Remarks: #
# . rmksysb can only be used by root #
# . this script will use tapedevice .1, so if #
# a >2.3GB drive is used: check density_set_1 #
# . the remote host needs /.rhosts to include the local host #
# for root access (+ shell enabled in /etc/inetd.conf) #
# . you will need some room (>1.5MB) on /tmp on the remote host #
# for standard mksysb .archive.list.* etc. #
# . remote standard output & standard error (except dd/chdev) #
# will go to local stdout & stderr #
# . redirecting stdout can create quite large log-files (2MB) #
# . AIX versions should not be too far apart as the boot-saveset#
# comes from the local system & the rest from the remote #
# (tested on AIX 3.2.5, AIX 4+ definitely won't work!!!) #
# . most likely this script will fail with multi-tape mksysb's: #
# another incentive to keep rootvg as small as possible! #




set +u

# Global variable definitions.
UMASK=`umask`
BLK_SZ=1024
BOOT_BLK_SZ=512
HOST=${1}

# TAPE = $2 with /dev/ & .* removed, defaulting to rmt0
TAPE=${2:-rmt0}
TAPE=${TAPE#/dev/}
TAPE=${TAPE%.*}

usage()
{
echo &quot;Usage: ./rmksysb <remote_host_name> [<tape_device>] or&quot; >&2
echo &quot; ./rmksysb -l [<tape_device>]&quot; >&2
echo &quot; with <tape_device>= e.g. rmt1&quot; >&2
echo &quot;Default <tape_device>=rmt0&quot; >&2
return
}

check_parms()
{
if [ &quot;${HOST}&quot; = &quot;&quot; ]
then
usage
exit 1
fi

if [ &quot;${HOST}&quot; = &quot;-l&quot; ]
then
# show TOC block which contains some backup details on rmksysb tapes
get_tape_block_size
chdev -l ${TAPE} -a block_size=${BOOT_BLK_SZ} >/dev/null 2>&1
mt -f /dev/${TAPE} rewind
mt -f /dev/${TAPE}.1 fsf 2
dd if=/dev/${TAPE} count=1 2>/dev/null
chdev -l ${TAPE} -a block_size=${OLD_BLK_SZ} >/dev/null 2>&1
exit
fi
}

check_host()
{
rsh ${HOST} hostname >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo &quot;Check hostname & rsh access&quot; >&2
exit 1
fi
}

get_tape_block_size()
{
VALID=
`lsdev -Cc tape | cut -f1 -d&quot; &quot; | grep ${TAPE} 2>&1 >/dev/null` &&
{
OLD_BLK_SZ=`lsattr -El ${TAPE} -a block_size | cut -f2 -d&quot; &quot;`
VALID=true
}

if [ &quot;$VALID&quot; = &quot;&quot; ]
then
echo &quot;Tape drive $TAPE is not a valid local drive!&quot; >&2
exit 1
fi
}

#
# The main procedure is analogous to its C counterpart,
# This is the basic driver routine.
#
main()
{

if [ &quot;`id | grep 'uid=0'`&quot; = &quot;&quot; ]
then
echo &quot;rmksysb can only be run as root!&quot; >&2
exit 2
fi
umask 022

check_parms
check_host
get_tape_block_size

# display some info on this rmksysb session
echo &quot;`date`\n\nRemote System Backup from remote ${HOST} to local `hostname` on device:\n`lscfg -v -l ${TAPE} | sed -n '3,6p' | grep &quot;[a-z]&quot; `\n&quot;

# Here the action starts
rsh $HOST -n /usr/bin/mkszfile
rsh $HOST -n &quot;echo ${BLK_SZ} > /tapeblksz&quot;

rsh $HOST -n &quot;rm -f /tmp/pipe.rmksysb&quot;
rsh $HOST -n &quot;rm -f /tmp/pipe.rmksysb.out&quot;
rsh $HOST -n &quot;rm -f /tmp/pipe.rmksysb.err&quot;

rsh $HOST -n &quot;/etc/mknod /tmp/pipe.rmksysb p&quot;
rsh $HOST -n &quot;/etc/mknod /tmp/pipe.rmksysb.out p&quot;
rsh $HOST -n &quot;/etc/mknod /tmp/pipe.rmksysb.err p&quot;

# create remote startup file for mkinsttape
rsh $HOST -n &quot;echo '#!/bin/ksh\nexport PATH=$PATH ; /usr/sbin/mkinsttape /tmp/pipe.rmksysb >/tmp/pipe.rmksysb.out 2>/tmp/pipe.rmksysb.err &' > /tmp/mkinsttape.start &quot;
rsh $HOST -n &quot;chmod 700 /tmp/mkinsttape.start&quot;

chdev -l $TAPE -a block_size=${BOOT_BLK_SZ} >/dev/null 2>&1
tctl -f /dev/${TAPE} retension

echo
echo
echo &quot;>>> SAVESET 1: BOS boot image from `hostname`&quot;
echo
bosboot -d /dev/${TAPE}.1 -a

echo
echo
echo &quot;>>> SAVESET 2: BOS install utilities from ${HOST} (backup format)&quot;
echo
rsh $HOST -n &quot;nohup /tmp/mkinsttape.start&quot; &

# get remote standard out & err to local stdout & err
rsh $HOST -n &quot;dd if=/tmp/pipe.rmksysb.out 2>/dev/null&quot; | dd 2>/dev/null &
rsh $HOST -n &quot;dd if=/tmp/pipe.rmksysb.err 2>/dev/null&quot; | ( dd 2>/dev/null ) >&2 &

# get remote mkinsttape to local tape device
rsh $HOST -n &quot;dd if=/tmp/pipe.rmksysb 2>/dev/null&quot; | dd 2>/dev/null | dd of=/dev/${TAPE}.1 conv=sync 2>/dev/null

echo
echo
echo &quot;>>> SAVESET 3: Backup information (list with ./rmksysb -l [<tapedevice>])&quot;
echo
# add dummy TOC to tape with some backup information
echo &quot;`date`\n\nRemote System Backup from remote ${HOST} to local `hostname` on device:\n`lscfg -v -l ${TAPE} | sed -n '3,6p' | grep &quot;[a-z]&quot; `\n&quot; | dd of=/dev/${TAPE}.1 conv=sync 2>/dev/null

# change blocksize to 1024 for better performance
chdev -l ${TAPE} -a block_size=${BLK_SZ} >/dev/null 2>&1

# rewind & skip first 3 savesets
mt -f /dev/${TAPE} rewind
mt -f /dev/${TAPE}.1 fsf 3

echo
echo
echo &quot;>>> SAVESET 4: mksysb (rootvg backup) from ${HOST} (tar format)&quot;
echo
# start the actual remote mksysb
echo &quot;The contents of the /.fs.size file on ${HOST} are:&quot;
rsh $HOST -n &quot;cat /.fs.size&quot;
echo

rsh $HOST -n &quot;nohup /usr/bin/mksysb /tmp/pipe.rmksysb >/tmp/pipe.rmksysb.out 2>/tmp/pipe.rmksysb.err &&quot; &

# get remote standard out & err to local stdout
rsh $HOST -n &quot;dd if=/tmp/pipe.rmksysb.out 2>/dev/null&quot; | dd 2>/dev/null &
rsh $HOST -n &quot;dd if=/tmp/pipe.rmksysb.err 2>/dev/null&quot; | ( dd 2>/dev/null ) >&2 &

# get remote mksysb to local tape device
rsh $HOST -n &quot;dd if=/tmp/pipe.rmksysb 2>/dev/null&quot; | dd obs=${BLK_SZ} 2>/dev/null | dd of=/dev/${TAPE} bs=${BLK_SZ} conv=sync 2>/dev/null

# cleaning up
rsh $HOST -n &quot;rm -f /tmp/pipe.rmksysb&quot;
rsh $HOST -n &quot;rm -f /tmp/pipe.rmksysb.out&quot;
rsh $HOST -n &quot;rm -f /tmp/pipe.rmksysb.err&quot;
rsh $HOST -n &quot;rm -f /tmp/mkinsttape.start&quot;

chdev -l ${TAPE} -a block_size=${OLD_BLK_SZ} >/dev/null 2>&1
umask $UMASK

# display some closing info on this rmksysb session
echo &quot;Remote System Backup from remote ${HOST} to local `hostname` is finished.\n`date`\n&quot;

} #end of main

# Call the driver
main

################## This is the end of rmksysb #################### --
| Mike Nixon
| Unix Admin
| ----------------------------
 
bootable is not a problem as it can be cloned, ill have to give that a shot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top