[GRLUG] Backing up Linux Servers

Chris Lamrock clamrock at nmtdie.com
Wed Sep 13 14:24:30 EDT 2006


Thanks for the ideas guys... I'm still looking into this but do appreciate 
the ideas!

-Chris


----- Original Message ----- 
From: "Kaminski, Dennis J" <Dennis.Kaminski at dematic.com>
To: <grlug at grlug.org>
Sent: Tuesday, September 12, 2006 9:37 AM
Subject: Re: [GRLUG] Backing up Linux Servers


> Here's a script I use to backup a system to a NFS mount on a HP-UX
> system. By using a UNIX/Linux system, I can ssh the information back
> during the restore. Since you're backing up to a M$ system, you'll have
> to do something different when you restore the file systems.
>
> The server has three file systems and is running RH ES4. The tar command
> is used on the third file system because there are 4 gig files that the
> 32 bit version of cpio doesn't back up. You won't need the lines that
> start with #--- because they are specific to stopping and starting the
> SAP application. The additional information I gather up front is
> overkill, but, its better to have too much than not enough.
>
>
> #!/bin/bash
> #
> #
> #---#       get the 6th char of the system name (d, t or p)
> #---XI_CHAR=`uname -n | cut -b6`
> XI_NAME=`uname -n`
> DIR=/bkup/$XI_NAME
> mkdir -p $DIR
> #---SAPLOG=$DIRsap.bounce.log
> BKLOG=$DIR/drbkup_cpio.log
> EMAILINFO=$DIR/email.info
> #---echo " " > $SAPLOG
> echo " " > $BKLOG
> echo " " > $EMAILINFO
> #
> #---#       stop sapXI
> #---date +%Y-%m-%d' '%T >>$SAPLOG
> #---su - xi${XI_CHAR}adm -c stopsap >>$SAPLOG 2>&1
> #---date +%Y-%m-%d' '%T >>$SAPLOG
> #
> #       gather information
> INFO=$DIR/drbkup_info
> cat /etc/resolv.conf    > ${INFO}_etc_resolve_conf
> cat /etc/fstab          > ${INFO}_etc_fstab
> cat /etc/hosts          > ${INFO}_etc_hosts
> cat /etc/redhat-release > ${INFO}_etc_redhat-release
> cat /etc/issue          > ${INFO}_etc_issue
> df -h                   > ${INFO}_df-h
> df -l                   > ${INFO}_df-l
> df -i                   > ${INFO}_df-i
> df -T                   > ${INFO}_df-T
> /sbin/fdisk -l          > ${INFO}_fdisk-l
> /sbin/ifconfig          > ${INFO}_ifconfig
> uname -a                > ${INFO}_uname-a
> ls -laR /               > ${INFO}_ls-laR 2>&1
> for X in `/sbin/fdisk -l|cut -d" " -f1|grep dev`
>    do "/sbin/dumpe2fs $X" > ${INFO}_dumpe2fs`echo $X | tr \/ _` 2>&1
>    done
> #
> #       backup the system
> date +%Y-%m-%d' '%T >$BKLOG
> set -o pipefail
> cd /boot ; find . -xdev | cpio -oacv 2>>$BKLOG | gzip -c >
> $DIR/drbkup_cpio_boot.gz 2>>$BKLOG
> RC_boot=$?
> cd /    ; find . -xdev | cpio -oacv 2>>$BKLOG | gzip -c >
> $DIR/drbkup_cpio_slash.gz 2>>$BKLOG
> RC_slash=$?
> tar -cvzf $DIR/drbkup_tar_sapdb.tgz /sapdb/* >>$BKLOG 2>>$BKLOG
> RC_sapdb=$?
> date +%Y-%m-%d' '%T >>$BKLOG
> #
> #---#       start sapXI
> #---date +%Y-%m-%d' '%T >>$SAPLOG
> #---su - xi${XI_CHAR}adm -c startsap >>$SAPLOG 2>&1
> #---date +%Y-%m-%d' '%T >>$SAPLOG
> #
> #
> BKSTATUS="OK"
> if [ $RC_boot != 0 ] ; then
>    BKSTATUS="Problem"
> elif [ $RC_slash != 0 ] ; then
>    BKSTATUS="Problem"
> elif [ $RC_sapdb != 0 ] ; then
>    BKSTATUS="Problem"
> fi
> echo '/      RC = ' $RC_slash     > $EMAILINFO
> echo '/boot  RC = ' $RC_boot     >> $EMAILINFO
> echo '/sapdb RC = ' $RC_sapdb    >> $EMAILINFO
> echo ' '    >> $EMAILINFO
> echo ' '    >> $EMAILINFO
> #---cat $SAPLOG >> $EMAILINFO
> mail -s "$BKSTATUS `hostname -s` `date +%Y%m%d_%H%M` nightly backup"
> root at localhost <$EMAILINFO
> #
> exit
>
>
>
> I use the following steps to rebuild the system:
> 1. Boot from Linux Install CD. Select the installation CD (install disk
> #1) based on Red Hat version (e.g. RH7, RHES3, RHES4) and whether the
> Linux installed was 32 bit or 64 bit.
>
> 2. Select linux rescue. Use "linux rescue" instead of "install". At the
> first prompt that comes up (boot:), type "linux rescue". If you wait too
> long, it will default to install.
>
> 3. Enter Network info. Use information from drbkup_info_ifconfig and
> drbkup_info_etc_resolve_conf files.
>
> 4. Partition disk using fdisk.
> fdisk devicename
> where devicename is:
> /dev/cciss/c0d0 for DL360 with hardware mirror disks or
> /dev/sda for desktop PCs.
> "p" to print any existing partition information.
> "d" to delete any existing partitions.
> "n" to create new partitions.
> "t" to change the partition type to swap.
> "a" to make the partition bootable.
> "w" to write the partition table and exit.
> The suggested steps are:
> 1. "p" print current partition information
> 2. "n" create new partitions to match the fdisk information
> 3. "t" change the appropriate partition type to swap
> 4. "a" make the appropriate partition bootable
> 5. "p" print new partition information and verify
> 6. "w" write the new partition information
>
> 5. Make file systems and label them using mkfs.ext3.
> mkfs.ext3 -L /boot /dev/cciss/c0d0p1
> mkfs.ext3 -L / /dev/cciss/c0d0p3
> Check for other file systems.
> Note: c0d0p2 is probably swap space and does not need a file system.
>
> 6. Format the swap space.
> mkswap -c /dev/cciss/c0d0p2
>
> 7. Mount the file systems.
> mkdir /mnt/slash
> mount /dev/cciss/c0d0p3 /mnt/slash
> mkdir /mnt/slash/boot
> mount /dev/cciss/c0d0p1 /mnt/slash/boot
>
> 8. Restore directories.
> cd  /mnt/slash
> ssh  drbkup at saplog "cat sapprt2.0/drbkup_cpio_slash.gz" | gunzip -c |
> cpio  -idmV
> cd  /mnt/slash/boot
> ssh  drbkup at saplog "cat sapprt2.0/drbkup_cpio_boot.gz" | gunzip -c |
> cpio  -idmV
>
> To restore a tar file (sapxip):
> cd /mnt/slash/sapdb
> ssh  drbkup at saplog "cat sapxip/drbkup_tar_sapdb.tgz" | tar -xzv
>
> 9. Run grub.
> /mnt/slash/sbin/grub
> At the grub prompt (grub >)
> grub >  root  (hd0,0) (disk 0, partition 0)
> grub >  setup (hd0)
> grub >  quit
>
> 10. Remove CD.
>
> 11. Reboot using "exit" command.
>
>
>
>
> Dennis J Kaminski
>
> -----Original Message-----
> From: grlug-bounces at grlug.org [mailto:grlug-bounces at grlug.org] On Behalf
> Of Chris Lamrock
> Sent: Tuesday, September 12, 2006 8:59 AM
> To: grlug at grlug.org
> Subject: [GRLUG] Backing up Linux Servers
>
> Hey guys,
>
> I've got 2 linux servers running here - one is a Gentoo box and one runs
> Red
> Hat.  I'd like to make images of the drives to an NFS share on a Windows
>
> Server - for disaster recovery purposes.  My 1st thought was dd...  to
> use
> dd I'd need to boot a live cd on the linux server and set up the NFS
> share -
> then do the dd to it correct?
>
> I also have Norton Ghost - I could use that I suppose...
>
> Any thoughts? Ideas?
>
> Thank you!
>
> -Chris
>
>
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
> _______________________________________________
> grlug mailing list
> grlug at grlug.org
> http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
>
> !DSPAM:45061054163101402352411!
> 




More information about the grlug mailing list