It’s ALWAYS a good idea to get a backup. Ideally, you should have a mirror and then break the mirror and stash a hard drive.
But… when your os install doesn’t seem to have all of the metadb commands, you should create a flash archive with flarcreate .
Here’s my fav’t method for managing a flar creation process.
All you have to do is run the script at the bottom of this post with the ip address of the server you want to flar to. The server must have /jumpstart/Flasharchives shared via nfs.
It will create a log file on the server and a backup directory on the server. It also will log errors to /var/adm/messages on the client.
ALSO, on the server, you can have /jumpstart/Flasharchives/<your client’s hostname>/<your client’s hostname>.copy and .exclude. The copy will result in a tarred up copy of files and directories you specify. For instance, your .copy file could be:
#Mycopy file
/etc/system
/kernel/drv
The above would copy /etc/system and /kernel/drv to a tar file on the server prior to the backup. This is useful if you want some files stored in a tar and not necessarily in the flar.
The exclude file is similar:
#my exclude file
/var/tmp/Software
The above would exclude /var/tmp/Software from the flar.
Enjoy!#!/bin/bash
# Creates a full flar and backup in:
# psrsunadm:/jumpstart/Flasharchives/$HOSTNAME.
#
# This is done by the following process:
# 1. Mount psrsunadm:/jumpstart/Flasharchives/$HOSTNAME
# 2. FLAR with $HOSTNAME.exclude
# 3. Copy $HOSTNAME.copy files to the mount point.
#
#
# ******************************************************************
# * You do not need to exclude /var/tmp/flarserver from your flash *
# * because the flash destination is excluded automatically. *
# ******************************************************************
#
# This script will accept one argument to indicate the desired
# flar server to use.
#
# ie. full_flar.sh 10.9.9.1 will flar to 10.9.9.1
#########################
# Variable Declarations #
#########################
[ -n "$1" ] && FLAR_SERVER=$1
[ -z "$FLAR_SERVER" ] && FLAR_SERVER=10.9.9.1
EXCLUDE=$HOSTNAME.exclude
INCLUDE=$HOSTNAME.copy
# don’t edit below this line
DATE=`date ‘+%Y.%m%d.%H%M’`
MOUNTPOINT=/var/tmp/flarserver
FLAR_DIR=/jumpstart/Flasharchives/$HOSTNAME
MOUNTPOINTHASBEENMOUNTED=0
SYSTEMFILECHANGED=0
#######################
# Function Definitons #
#######################
log()
{
logger “FULLFLAR: $1″
}
logerror()
{
logger “FULLFLAR: ERROR: $1″
[ $MOUNTPOINTHASBEENMOUNTED -eq 1 ] && umount $MOUNTPOINT
[ $SYSTEMFILECHANGED -eq 1 ] && mv /etc/system.bak /etc/system
echo “$HOSTNAME unsuccessfully backed up on $DATE.” >> $MOUNTPOINT/$HOSTNAME.log
exit 1
}
log “Begin flar to $FLAR_SERVER.”
#############################
# Step 1: Mount FLAR_SERVER #
#############################
# Prepare to mount!
if ! [ -d $MOUNTPOINT ]; then
if [ `mkdir $MOUNTPOINT` ];then
logerror “Unable to create mountpoint $MOUNTPOINT.”
fi
fi
# Mount!
if [ "`mount -F nfs -o public $FLAR_SERVER:$FLAR_DIR $MOUNTPOINT 2>&1`" != "" ]; then
logerror “Unable to mount $FLAR_SERVER:$FLAR_DIR to $MOUNTPOINT.”
else
MOUNTPOINTHASBEENMOUNTED=1
fi
######################
# Step 2: copy files #
######################
# Copy all files from <server>.include to the flarserver.
touch $MOUNTPOINT/$HOSTNAME-$DATE.tar
if [ `cat $MOUNTPOINT/$INCLUDE|grep -v "^#"|xargs -n1 tar -rhf $MOUNTPOINT/$HOSTNAME-$DATE.tar -C /` ]; then
logerror “Unable to backup $INCLUDE files…”
fi
###########################
# Step 3: FlAr the Client #
###########################
# We must remove mirror / raid stuff from /etc/system
# before we FlAr the system because when it comes up
# we don’t want it to be mirrored.
# old method: cat /etc/system.bak|grep -v md > /etc/system
if [ `cp /etc/system /etc/system.bak` ];then
logerror ‘Unable to backup /etc/system.’
fi
echo ‘Setting up /etc/system to not mount mirrors and raids after boot.’
if [ `cat /etc/system.bak|grep -v 'forceload:\ misc/md_'|grep -v 'rootdev:/pseudo/md\@'|grep -v 'set\ md:mddb_bootlist' > /etc/system` ];then
logerror “Unable to remove mirror and RAID loads from /etc/system.”
else
SYSTEMFILECHANGED=1
fi
# Create the FlAr
if ! [ `cat -s $MOUNTPOINT/$EXCLUDE |grep -v "^#" | flarcreate -n $HOSTNAME-$DATE -c -S -X - $MOUNTPOINT/$HOSTNAME-$DATE.flar` ]; then
logerror “Unable to create flash archive.”
fi
# Replace the original system file
echo “Putting /etc/system back to it’s orignal state so that it mounts mirrors and RAIDs.”
if [ `mv /etc/system.bak /etc/system` ]; then
logerror “Unable to mv /etc/system.bak to /etc/system.”
fi
# Create a log of the success on the jumpstart server
echo “$HOSTNAME successfully backed up on $DATE.” >> $MOUNTPOINT/$HOSTNAME.log
log “Successfully FlAred.”
#finally, unmount
if [ $MOUNTPOINTHASBEENMOUNTED -eq 1 ]; then
if [ `umount $MOUNTPOINT` ]; then
echo “Unable to unmount $MOUNTPOINT.”
echo “Please unmount it manually.”
exit 1;
fi
fi