User Tools

Site Tools


linux:backup_rear

This is an old revision of the document!


Backup all linux servers on a central server

REAR is an utility to install on Linux server (package: rear). With this tool, you can backup your OS, and more…

Configure the client to be able to backup on a nfs server

[root@linux1 rear]# cat site.conf
OUTPUT=ISO
BACKUP=NETFS
BACKUP_URL="nfs://aixsrv1/export/rear/"
REAR_INITRD_COMPRESSION="lzma"
AUTOEXCLUDE_MULTIPATH=N
AUTOEXCLUDE_DISKS=Y

On AIX server (or linux), configure NFSv4 Ex:

[root@aixsrv1]/export/rear# cat /etc/exports
/export/rear -vers=3:4,rw,root=linux1:linux2:10.0.0.123
[root@aixsrv1]/export/rear# cat /root/scripts/rear.sh
#!/bin/ksh93
#set -x
################################################
#@(#) Create a rear backup for all linux clients
################################################
# version 1.0
#############################################

dir=`dirname $0`
. $dir/.env

rearbackup="linux1 linux2"
rearpath=/export/rear

HOSTNAME=$(hostname -s)

dest="test@yahoo.fr"
sender="${HOSTNAME}@yahoo.fr"

errlog=$logpath/${sn}_err.out
detail=$logpath/${sn}_detail.out
start_time=$(date "+%d-%m-%Y %H:%m")

#------------------------------------------------
usage ()
{
echo "Usage: "$0 [linuxname1,linuxname2...]
echo "\t<linuxname> is optional"
echo "\twithout parameters will create rear backup for all known linux partitions on local site"
echo "\tIf you add a specific linux, then only that linux will be saved"
exit 1
}

#------------------------------------------------
initialize ()
{
cat /dev/null > $errlog
cat /dev/null > $detail
cat /dev/null > $logname
}

#------------------------------------------------
mkrear ()
{

for client in ${rearbackup}
do
    ssh $client "/usr/sbin/rear mkbackup"
    if [ $? -ne 0 ]
    then
      echo "Rear backup for $client failed" >> $errlog
    else
      size=$(du -sg $rearpath/$(echo ${client}|cut -d. -f1)/ | awk '{print $1}')
      echo "Rear backup size"
      echo "$size GB $rearpath/${client}"

      print "***** mksysb Successful on host $client *****"
      print "Successful rear on host $client : size $size GB" >> $logname
      echo
    fi
done
}


#------------------------------------------------
sendemail ()
{
echo "###############" > $logname.tmp
echo "### $HOSTNAME ###" >> $logname.tmp
echo "###############" >> $logname.tmp
echo "\tRear started at: ${start_time}" >> $logname.tmp
#echo "\tRear ended at: "$(date "+%d-%m-%Y %H:%m") >> $logname.tmp
if [ -s $errlog ]
then
  echo "\n######## Failed rear ########" >> $logname.tmp
  cat $errlog >> $logname.tmp
  echo "Detailled error on $HOSTNAME $detail"
fi
echo "\n######## Successful rear ########" >> $logname.tmp
cat $logname >> $logname.tmp
echo | mailx -a $logname.tmp -r "$sender" -s "Report rear on $HOSTNAME" $dest
#test -f $logname.tmp && rm $logname.tmp
}

#############################################
# main
#############################################

case "$*" in
  help|-h|-help) usage ;;
esac

initialize
mkrear $* > $detail 2>&1
sendemail
linux/backup_rear.1609532710.txt.gz · Last modified: 2021/01/01 21:25 by 127.0.0.1