SLAC ESD Software Engineering Group
Stanford Linear Accelerator Center

System Disk Backup

for Servers and OPI's

SLAC Computing
Software Engineering
Detailed
Unix
 

 

 


 The Linux servers and OPI workstations system disks are backed up once a month using the "dd" command.  The script performs the backup and sends an email confirming SUCCESS or FAILURE.  On our LCLSDMZ Servers we use the root crontab file and on our LCLSCA Servers we the crontab.monthly directory.  We also run a chk_linuxdd script on lcls-uwd as "uwd" to check on each host and make sure the backup was run.  An email listing the servers that did not have a log file is sent to the system admins.


 

 

root crontab entry (DMZ):

 

 

 

42 4 1 * * /afs/slac/g/lcls/tools/script/linuxdd > /tmp/linuxdd.log 2>&1

/etc/cron.monthly directory (LCLSCA):

 

 

 

lrwxrwxrwx 1 root root 32 Jul 16 14:20 linuxdd -> /usr/local/admin/scripts/linuxdd

 

linuxdd script:  $TOOLS/script/linuxdd

 

chk_linuxdd:  $TOOLS/script/chk_linuxdd

uwd crontab file:  30 8 1 * * /afs/slac/g/lcls/tools/script/chk_linuxdd > /tmp/chk_linuxdd.log 2>&1

 

RHEL-5 Grub related issues and solutions –

Important files -

/boot/grub/grub.conf

/etc/fstab

/boot/grub/device.map 

Our standard mechanism for root disk mirroring is dd. We also have a linux-mirror script which uses dump command.

If following files contain references to disk partition LABELs then we can face bizarre issues due to disk mirroring –

 /boot/grub/grub.conf

/etc/fstab

 

/etc/grub.conf would look like following (without LABEL entries) –

[root@mcclogin ~]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sda1
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=7
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Client (2.6.18-308.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-308.el5 ro root=/dev/sda1
initrd /boot/initrd-2.6.18-308.el5.img
title Red Hat Enterprise Linux Client (2.6.18-308.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-308.el5PAE ro root=/dev/sda1
initrd /boot/initrd-2.6.18-308.el5PAE.img

/etc/fstab would look like following (without LABEL entries) –

[root@mcclogin ~]# cat /etc/fstab
/dev/sda1 / ext3 defaults 1 1
/dev/sda8 /scratch ext3 defaults 1 2
/dev/sda7 /scswork ext3 defaults 1 2
/dev/sda6 /usr/vice/cache ext3 defaults 1 2
/dev/sda5 /tmp ext3 defaults 1 2
/dev/sda3 /var ext3 defaults 1 2
mccfs2:/export/mccfs/u1 /mccfs2/u1 nfs defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc nosuid 0 0
/dev/sda2 swap swap defaults 0 0

  

 

Other important file which can cause unbootable mirror disk –

/boot/grub/device.map

Before mirroring the disk, ensure that this file contains entries for all the disks currently installed in the server.

 

In case of any discrepancies, recreate the /boot/grub/device.map file by issuing following commands –

mv  /boot/grub/device.map  /boot/grub/device.map.bak

echo  | grub   --device-map=/boot/grub/device.map

Note – The “echo |”   will make the grub command non-interactive.

For a server having two disks (root and root-mirror ), the /boot/grub/device.map file would look like following -

[root@mcclogin ~]# cat /boot/grub/device.map
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb

How to find out LABEL of a file system ?

By using e2label command.

For example -

# e2label /dev/sda1
/ROOT

Small script for converting LABEL entries of /etc/fstab -

#!/bin/bash
declare -a MYRA
MYRA=($(/bin/grep LABEL /etc/fstab | /bin/cut -d " " -f 1))

#iecho number of elements ${#MYRA[*]}
#echo number of elements ${#MYRA[@]}
/bin/cp /etc/fstab /etc/fstab.bkup
/bin/cp /etc/fstab /etc/fstab.intermed
for LABELID in ${MYRA[@]}
do
DEVNAME=($(/sbin/blkid -t $LABELID | /bin/cut -d " " -f 1 | /bin/cut -d ":" -f1))
if [ "$DEVNAME" != "" ]
then

echo Replacing $LABELID with $DEVNAME
/bin/cat /etc/fstab.intermed |/bin/sed "s#$LABELID #$DEVNAME #g" > /etc/fstab.intermed2
/bin/cp /etc/fstab.intermed2 /etc/fstab.intermed
rm -rf /etc/fstab.intermed2
else
echo blank
fi
done
/bin/mv /etc/fstab.intermed /etc/fstab

 


 


[SLAC ESD Software Engineering Group][ SLAC Home Page]


Author:K. Brobeck

Modified: 02-Mar-2012