I'm newbee in AIX.
I'd like to backup file system(/, /home, /src, /A, /B) in one 8mm 5GB Tape.
I'd like to backup filesystem periodically.
And then if some problem will occur, I will restore filesystem using Tape.
But I'm now in struggle in backing up system.
I had plan to use below script.
/usr/sbin/backup -0uf /dev/rmt0.1 /
/usr/sbin/backup -0uf /dev/rmt0.1 /home
/usr/sbin/backup -0uf /dev/rmt0.1 /src
/usr/sbin/backup -0uf /dev/rmt0.1 /a
/usr/sbin/backup -0uf /dev/rmt0.1 /b
Before using above script, I have tested backup with /var and /tmp filesystem.
But, there is no success.
Thus, I'd like to receive good example script of backup and restore
filesystem.
Thanks in advance.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
This is a stripped down version of my backup script. I had to remove
a bunch of stuff for security reasons but most of that applied to our
database. I run this every night to a different tape via cron sometime
in the middle of the night. You should back up the root volume group
using mksysb instead of backup because that makes the tape bootable
and in the event of a hardware failure you can rebuild your system from
tape.
#!/usr/bin/ksh
TAPE=/dev/rmt0
export TAPE
cd /
/usr/bin/tctl -f /dev/rmt0 retension
/usr/bin/mksysb -i /dev/rmt0
tctl -f /dev/rmt0.1 fsf 4
# restore -s 5 -xdqf /dev/rmt0.1 . from beginning of the tape to restore for /osmdbf
cd /osmdbf
/usr/bin/find . -print | /etc/backup -i -q -f /dev/rmt0.1
# restore -s 6 -xdqf /dev/rmt0.1 for /oracle7
cd /oracle7
/usr/bin/find . -print | /etc/backup -i -q -f /dev/rmt0.1
# restore -s 7 -xdqf /dev/rmt0.1 for /x3
cd /x3
/usr/bin/find . -print | /etc/backup -i -q -f /dev/rmt0.1
/usr/sbin/tapechk 19
tctl -f /dev/rmt0.1 fsf 3
restore -Tq -f /dev/rmt0.1 > /tmp/rootvg.list
restore -Tq -f /dev/rmt0.1 > /tmp/osmdbf.list
restore -Tq -f /dev/rmt0.1 > /tmp/oracle7.list
restore -Tq -f /dev/rmt0.1 > /tmp/x3.list
tctl -f /dev/rmt0 rewind
exit 0
I've written a backup utility that creates full backups and differentials using
the AIX backup command. I also prune files out you probably do not wish to backup
anyway (like dev files, .o files, core files, and tmp files). You should still
use mksysb to create a rootvg backup though, otherwise you'ld have to install AIX
from the install media, and then restore this backup, and then reconfigure alot of
things on the system. I run my backupscript in cron every night, but you can also
run it from the command prompt. To start the whole thing off, I created a file
called EPOCH ( # > EPOCH) and touched it to be date 1-1-1970 so I would get my
first full baclup. I have a directory structure /d/backup that contains all my
backup stuff. in this directory I have sub-directories .LOG, .TOUCH, and .TAPE.
within .LOG I have directories FULL and HALF (I'm a football fan, so I chose to
call the differential directory HALF, and it's shorter too. In the .TOUCH
directory, I keep the information regarding when the last backup was done, and
what type it was (actually all the backups). In the .TAPE directory I keep a list
of all my tapes, and what they have been used for, so I know how many times I've
used them, and when to replace them. I label the tapes by puttinf a empy file on
them as the first file that is the tape name, and that's how I track the tapes.
Finally, in the .LOG/???? directory is a log of all the files on the particular
tape, that way I can find the correct tape to restore from quickly. Anyway, here
is my backup script.
###******* backup_script
#!/bin/ksh
PATH="/u/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/sbin"
BKHOME="/d/backup"
if [[ ${1} = "-td" ]]
then
TAPEDRIVE="/dev/rmt${2}"
shift;shift
else
TAPEDRIVE="${TAPEDEV:-/dev/rmt1}"
fi
BKUPTYPE="${1:-ZxZ}"
BKUPDATE="`date +%y%m%d`"
TTY="`tty 2>/dev/null`"
COMPRESSION="p" # set to "p" for backup if you want compression
export PATH TAPEDRIVE TTY BKUPDATE BKUPTYPE BKHOME
# is this a cron job or running on a terminal
if [[ ( ${TTY} != "tty: 0551-011 Standard input is not a tty." ) ]]
then
BUPROMPT=""
else
BUPROMPT="-q"
fi
###
###
### get the TAPE NAME
###
TAPENAME="`dd if=${TAPEDRIVE} ibs=10240 count=1 2>/dev/null | \
restore -T -f - 2>/dev/null | \
grep BACKUP | \
head -1 | \
cut -f1 -d!`"
echo "TAPE IN DRIVE IS LABELED: \"${TAPENAME}\""
BKUPLFN="${TAPENAME:-${BKUPDATE}}"
if [[ ${BKUPTYPE} = "ZxZ" ]]
then
BKUPTYPE="HALF"
fi
cd /
if [[ ( ${BKUPTYPE} != "HALF" ) && ( ${BKUPTYPE} != "FULL" ) ]]
then
BKUPTYPE="HALF"
fi
cd ${BKHOME}
cd .TOUCH/FULL
BKUPTCHFILE="`ls -lt * | head -1 | cut -c55-`"
cd ${BKHOME}
rm -f ${BKHOME}/.TOUCH/${BKUPTYPE}/${BKUPLFN}
echo ${BKUPDATE} > ${BKHOME}/.TOUCH/${BKUPTYPE}/${BKUPLFN}
case ${BKUPTYPE} in
HALF)
FSTRING=" -newer ${BKHOME}/.TOUCH/FULL/${BKUPTCHFILE} ";;
FULL)
FSTRING=" ";;
esac
cd /
cat > ${BKHOME}/bucmd.$$ <<GROK
cd /
echo "${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE}"
find . ${FSTRING} -print |\
grep -v '^\./cd0/'|\
grep -v '^\./CDrom/'|\
grep -v '\.o$' |\
grep -v '/core' |\
grep -v '^\./dev/' |\
grep -v '^\./tmp/' |\
grep -v '^\./usr/spool/lp'
GROK
chmod 750 ${BKHOME}/bucmd.$$
### ${BKUPCMD} ### actually run backup
###########################################
#
# display the date/time the backup starts
echo "starting ${BKUPTYPE} backup at `date`"
#
# set the block length on the tape drive
/usr/sbin/chdev -l "`basename ${TAPEDRIVE}`" -a block_size="1024"
# unmount the CD-ROM
/usr/sbin/umount /cd0
#
# pipe the find thru backup to actually write the tape
touch /${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE}
/bin/rm -f ${BKHOME}/.LOG/${BKUPTYPE}/${BKUPLFN} >/dev/null 2>&1
${BKHOME}/bucmd.$$ | \
backup -i${COMPESSION}v ${BUPROMPT} -f ${TAPEDRIVE} | \
tee ${BKHOME}/.LOG/${BKUPTYPE}/${BKUPLFN}
#
# log the backup in the tape history
echo ${BKUPDATE}:${BKUPTYPE} >> ${BKHOME}/.TAPE/${TAPENAME}
#
# remove the find script
/bin/rm ${BKHOME}/bucmd.$$
sleep 120
#
# reset the tape drive to variable block length
/usr/sbin/chdev -l "`basename ${TAPEDRIVE}`" -a block_size="1024"
#
# eject the tape
/bin/mt -f ${TAPEDRIVE} rewoffl
#
# remount the CD-ROM
/usr/sbin/mount /cd0
rm /${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE}
if test ! "${BUPROMPT}" >/dev/null 2>&1
then
echo "";echo ""
echo "Backup has Finished. Press <ENTER> to Exit. \c"
read resp
fi
###******* end of backup_script
and here is the script I use to label the tapes.
###******* beggining of tape labeling script
#!/bin/ksh
if [[ ${1} = "-td" ]]
then
TAPEDRIVE="/dev/rmt${2}"
shift;shift
else
TAPEDRIVE="/dev/rmt1"
fi
BKHOME="/d/backup"
NTAPENAME="${1:-ZxZ}"
BKUPDATE="`date +%y%m%d`"
TTY="`tty 2>/dev/null`"
BKUPTYPE="INIT"
export TAPEDRIVE TTY BKUPDATE BKUPTYPE BKHOME
###
###
### get the TAPE NAME
###
if [[ ${NTAPENAME} = "ZxZ" ]]
then
TAPENAME="`dd if=${TAPEDRIVE} ibs=10240 count=1 2>/dev/null | \
restore -T -f - 2>/dev/null | \
grep BACKUP | \
head -1 | \
cut -f1 -d!`"
else
TAPENAME=""
fi
tput clear
echo;echo;echo;
echo "TAPE IN DRIVE IS LABELED: \"${TAPENAME}\""
if [[ ${TAPENAME} = "" ]]
then
if [[ ${NTAPENAME} = "ZxZ" ]]
then
echo "what is the name of the tape: \c"
read NTAPENAME
TAPENAME="${NTAPENAME}"
else
TAPENAME="${NTAPENAME}"
fi
else
echo "cannot label a labeled tape, exiting!"
exit 0
fi
cd /
echo "${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE}"
#
# set the block length on the tape drive
/usr/sbin/chdev -l "`basename ${TAPEDRIVE}`" -a block_size="1024"
#
# pipe the find thru backup to actually write the tape
touch /${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE}
echo ${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE} |
backup -ipv -f ${TAPEDRIVE}
touch ${BKHOME}/.TAPE/${TAPENAME}
#
# log the backup in the tape history
echo ${BKUPDATE}:${BKUPTYPE} >> ${BKHOME}/.TAPE/${TAPENAME}
#
# reset the tape drive to variable block length
/usr/sbin/chdev -l "`basename ${TAPEDRIVE}`" -a block_size="0"
#
# eject the tape
/bin/mt -f ${TAPEDRIVE} rewoffl
rm /${TAPENAME}!!BACKUP!!${BKUPDATE}:${BKUPTYPE}
###******* beggining of tape labeling script
jck...@my-dejanews.com wrote:
> Hi all.
>
> I'm newbee in AIX.
> I'd like to backup file system(/, /home, /src, /A, /B) in one 8mm 5GB Tape.
> I'd like to backup filesystem periodically.
> And then if some problem will occur, I will restore filesystem using Tape.
>
> But I'm now in struggle in backing up system.
>
> I had plan to use below script.
>
> /usr/sbin/backup -0uf /dev/rmt0.1 /
> /usr/sbin/backup -0uf /dev/rmt0.1 /home
> /usr/sbin/backup -0uf /dev/rmt0.1 /src
> /usr/sbin/backup -0uf /dev/rmt0.1 /a
> /usr/sbin/backup -0uf /dev/rmt0.1 /b
>
> Before using above script, I have tested backup with /var and /tmp filesystem.
> But, there is no success.
>
> Thus, I'd like to receive good example script of backup and restore
> filesystem.
>
or ADSM do require files/file systems as backup input. From various IBM Web
documentation results that there is something called ADSMPIPE that allows to copy raw
device content to tape.
Please allow these questions:
1. Do you know anything about this ADSMPIPE and can you tell me about any experience?
2. What other hints can you give me about backing up raw devices with AIX?
Thank you for your attention,
Regards, Igor
PS: Your name sounds German, so if you prefer we can also write in German.
To backup your databases with ADSM, look at the ADSM Oracle connect Agent.
You can buy it from IBM. Look on IBM's site for the Red Books and White
Papers on backing up DBMS's with ADSM (a little bit out-of-date now, but
still a good overview). It also supports raw devices. The Agent works with
EBU (oracle7) and RMAN (Oracle8).
>2. What other hints can you give me about backing up raw devices with AIX?
I use 'dd', which I think is your only 'out-of-the-box' solution for AIX.
You can obviously buy other backup products like ADSM, SQL-Backtrack, etc.,
etc., that support raw devices.
My approach is to put each db in it's own VG, and split the areas of the db
into separate LV's (redo, rollback, data, index, etc.) It's then easy with
the lsvg command to pick up the lv's that comprise your database. I also
always prefix the vg's and lv's with the database SID, and I make the lv's
in <SID>_<PART><No.> format, ie lv's for a database called 'ORADB' might be
'oradb_redo01', 'oradb_temp01', 'oradb_temp02', etc. Again, it makes the
management easier, as you can put the whole backup process in a simple
script which loops through the lv's for each database.
I tend to lump the raw db backups in with my main file system backup's (we
have big fast tapes). I do a 'dd' of each partition to a disk-based file
first and 'compress' it. Compression usually runs at around 3-4 to 1 for
database files. I leave the compressed files on disk for faster recovery
should we need them. If you can't afford the disk space for this, just dd
direct to tape.
MotoX.
> Hi Walter,
> I read your interesting article about the backup procedure and script.
> I am not really new to Unix (6 years), but I am not really familiar with AIX yet. And
> I don't have the machines yet (two RS/6000 SP nodes).
> In fact, what we are planning to do is to install Oracle on those systems that will
> use data files based on raw device access, so no file system. As far as I know, backup
>
> or ADSM do require files/file systems as backup input. From various IBM Web
> documentation results that there is something called ADSMPIPE that allows to copy raw
> device content to tape.
>
> Please allow these questions:
> 1. Do you know anything about this ADSMPIPE and can you tell me about any experience?
> 2. What other hints can you give me about backing up raw devices with AIX?
>
> Thank you for your attention,
> Regards, Igor
>
> PS: Your name sounds German, so if you prefer we can also write in German.
Here's mine. Use it as a guide only. You'll have to write one for your system.
#! /usr/bin/ksh
# NAME: backupall <Backup All>
# AUTHOR: Jeffrey Fulmer
# EMAIL: jfu...@voicenet.com
# DATE: TUE Nov 11 12:09:11 EST 1998
# SYNOP: Backs up all files in the specified directories. Finds all the
# files and appends them to a backup list. The backup list is
# read by backbyname.
# VERSION: 1.0 -- TUE Nov 11 12:12:45 EST 1998
# Performed basic functions in the synop
# VERSION: 1.1 -- MON Jan 19 14:33:10 EST 1998
# Added the backup.log conditional, displayed the directories
# the script was cateloging.
# VERSION: 1.2 -- MON Jun 01 07:43:18 EDT 1998
# Time stamped the stderr output to separate files. Moved the
# files to /home/jfulmer/logs.
# VERSION: 1.21-- MON Jul 06 15:17:12 EDT 1998
# Ported to Ruy from Tal
# VERSION: 1.22-- THU Jul 09 15:25:12 EDT 1998
# Added brief online help largely because I tend to forget how
# to restore files: backup -? OR -h
##########/
if [[ $1 = "-h" ]] || [[ $1 = "-?" ]]; then
echo "To run the script: backupall <no params>"
echo "To verify a backup: restore -Tf /dev/rmt0"
echo "To restore a dir: restore -vf /dev/rmt0 -d <directory>"
exit
fi
if [[ ! -a /home/jfulmer/logs/backup.log ]]; then
echo "------------------------------------------------------------------------" >
/home/jfulmer/backup.log
echo "# Backup.log file" >> /home/jfulmer/backup.log
echo "# This file was generated automatically by the backup script...." >>
/home/jfulmer/backup.log
echo "# Location: /usr/bin/backupall" >> /home/jfulmer/backup.log
echo "------------------------------------------------------------------------" >>
/home/jfulmer/backup.log
fi
if [[ -a /tmp/backup.list ]]; then
rm /tmp/backup.list
echo "Removing old backup.list"
fi
start=`date`
echo "Backing up all files in the filesystems at $start,">>/home/jfulmer/backup.log
cd /
echo "Cataloging all files in /data...."
find /data -print >> /tmp/backup.list
echo "backing up to tape...."
# 3-10-98 added a timestamp to stderr output
cat /tmp/backup.list | backup -iqvf /dev/rmt0 2>>/home/jfulmer/backuperr.`date '+%m%d%y'`
stop=`date`
echo " ended at $stop.">>/home/jfulmer/backup.log
# To verify a backup: restore -Tf /dev/rmt0
# To restore a dir: restore -vf /dev/rmt0
The guy said he was on *raw* disks.
MotoX.
Jeffrey Fulmer wrote in message <35BF592C...@whiteoaknet.com>...
dd if=/dev/<X> of=/dev/<Y> bs=<Z>
X= Raw Filesystem LV name
Y= Tape drive
Z= Block size
This is a horrible way, but the only real way I know!!!..
John
I can't comment on ADSM, but we run UDB5 with all the containers on DMS
raw volumes. I use sysback to "back up logical volumes" (each one of
these being a container) and have had no problems. Restore can be done
to the original volume group or a different one, as long as space allows.
In addition to the raw devices, I get the filesystems for the instances,
logs, and etc. (for UDB) giving me a sort of snapshot of the database.
The only catch for me is that I can't just restore -one- tablespace
without corrupting the database, it is an all-or-nothing deal. Not very
nice on a 580 gigabyte database. I don't know if you will have the same
concern with oracle...
On Tue, 11 Aug 1998, Guyver wrote:
> If you are using RAW vols the only way to backup is with the luvley 'dd'
> This is a horrible way, but the only real way I know!!!..
>
> MotoX wrote:
>
> > Er, this won't work, will it?
> >
> > The guy said he was on *raw* disks.
> >