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 versions 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).
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:
TROUBLESHOOTING:
---------------
1. I'm seeing the error message:
cpio: can't open /dev/tty for writing
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.
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.
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. When reading the tape, I am getting "cpio: Impossible file type"
or "header type".
You are trying to read a 'tar' not a 'cpio' archive.
4. I am getting the following errors:
"Permission denied" "WARNING: Reserved tape failed to release!"
Check the tape is not set to read/only.
|