From owner-freebsd-questions Mon Sep 13 7:44:40 1999 Delivered-To: freebsd-questions@freebsd.org Received: from iaces.com (horton.iaces.com [204.147.87.98]) by hub.freebsd.org (Postfix) with ESMTP id EFD9C15583 for ; Mon, 13 Sep 1999 07:44:28 -0700 (PDT) (envelope-from proot@iaces.com) Received: (from proot@localhost) by iaces.com (8.9.3/8.9.3) id JAA04995; Mon, 13 Sep 1999 09:43:53 -0500 (CDT) From: "Paul T. Root" Message-Id: <199909131443.JAA04995@iaces.com> Subject: Re: SCSI drive mirroring question In-Reply-To: from Andriss at "Sep 13, 99 10:10:10 am" To: andriss@andriss.com (Andriss) Date: Mon, 13 Sep 1999 09:43:53 -0500 (CDT) Cc: questions@FreeBSD.ORG X-Organization: USWEST !nterprise Networking - ACES X-Phone: (612) 664-3385 X-Fax: (612) 664-4779 X-Page: (800) SKY-PAGE PIN: 537-7270 X-Address: 600 Stinson Blvd, Fl 1S X-Address: Minneapolis, MN 55413 X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM937233833-4549-0_ Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --ELM937233833-4549-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit In a previous message, Andriss said: -- Start of PGP signed section. > Hello, > > I have two identical UltraStar 18es drives from IBM, and I am planning > to mount the second drive on the SCSI bus of the FreeBSD 3.2 box and > use it to make nightly mirror copies of the first one. I know a few > ways to do this, but obviously it has to be done at night, and > without downtime for the box. > > It sounds easy: I need to make a script, and put it into crontab for > like 4am or so. > > (in the example below, I am assuming that the first drive is da0 and > the second drive is da1...) > > > > #!/bin/sh > > #device copying the drives > /bin/cp /dev/rda0 /dev/rda1 I don't think so. Try dump/restore. Enclosed is my script and data file for it. Fill out the data file for your file systems > > > Is that the right way to do this? What I want to get is a complete > mirror copy. I need to make sure that the boot info is getting copied, > and the filesystem slices are getting copied right.. In other words, > if the first drive fails, I want to be able to simply take it out, > switch the SCSI id of the second drive, boot the box and be ready to > go... Actually, you'll be able to do a boot sd(1) > Any comments would be greatly appreciated. > > > Andriss > > -- > ______________________________________________________________ > Andrey Kholodenko http://www.andriss.com > Download My Public PGP Key From http://www.andriss.com/pgp.txt > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > -- End of PGP signed section, PGP failed! -- The man over there said it was okay... Well, he was there a minute ago. --from "Excuses, Excuses" *the* compendium of excuses by Leigh W. Rutledge --ELM937233833-4549-0_ Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=backup.online Content-Description: /usr/local/sbin/backup.online Content-Transfer-Encoding: 7bit #!/bin/sh # # This is the first attempt at moving it to another platform # (FreeBSD) and making it more portable by using input files. # # This program creates a backup of the core files systems of # the machine so that if the primary disk dies, a mirror # image can be brought up very quickly. The program can # be run via cron and output sent to an email address. # # Unfortunately this program is pretty specialized for a # specific machines installation, but should be fairly # easy to modify. # # Originally written by Daniel Carlin (dcarlin@uswest.com), # this updated version handles the new hardware. # # This script makes a few assumptions. Like, that the /broot # mount point exists with proper ownership and permissions # (755 root.root), and that /etc/vfstab.bkp exists. # # # RCS_ID = $Id: backup.online,v 1.6 1999/08/13 16:26:58 proot Exp $ # # Log = $Log: backup.online,v $ # Log = Revision 1.6 1999/08/13 16:26:58 proot # Log = Hmm, I'll try to remember everything. # Log = FreeBSD can't mount a FS that's marked RO in the fstab as RW. # Log = Order of RO remount is special (subdirectories first). # Log = Solaris can't remount to RO so you have to unmount and remount # Log = so can't RO mount a FS with a subdirectory that's a FS. # Log = # Log = Revision 1.5 1999/08/12 12:14:14 proot # Log = -o rw NOT -rw. errg. # Log = # Log = Revision 1.4 1999/08/11 14:52:28 proot # Log = SunOS can't remount to read-only # Log = # Log = Revision 1.3 1999/08/11 14:36:44 proot # Log = found update in FreeBSD is remount in SunOS. # Log = # Log = Revision 1.2 1999/06/24 18:30:33 proot # Log = fixing log message # Log = export PATH PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin" date OS=`/usr/bin/uname` export OWN GROUP PERM OWN="root" PERM="755" # System Specific things export DEV RDEV DUMP RESTORE FSTAB if [ "$OS" = "SunOS" ]; then DEV="/dev/dsk/" RDEV="/dev/rdsk/" DUMP="/usr/sbin/ufsdump" RESTORE="/usr/sbin/ufsrestore" GROUP="sys" FSTAB=/etc/vfstab MINUSN='' BACKC="\c" # ROPT="-o ro" # Not needed elif [ "$OS" = "FreeBSD" ]; then DEV="/dev/" RDEV="/dev/r" DUMP="/sbin/dump" RESTORE="/sbin/restore" GROUP="wheel" FSTAB="/etc/fstab" MINUSN="-n" BACKC='' ROPT="-o ro,update" fi # Read in the data file to configure # The data file must contain the following # environment variables (then also need to # be exported: # $FS, $SFS, $MOUNT, $SRCFS, $LIST and $HFS DATA="/usr/local/etc/online.dat" . $DATA # Unmount the partitions to re-make the partitions echo "Unmount $FS" for i in `echo $SFS` do umount $HFS/$i done umount $HFS # Newfs everytime so we know the partition is in good shape echo echo "Creating new file systems..." echo for i in `echo $LIST` do eval 'echo "y" |newfs -m 2 -o space ${RDEV}$'${i} eval 'fsck -y ${RDEV}$'${i} done # Remount the partitions. Note: fstab has these set RO. echo echo "Mount $FS" mount -o rw $HFS for i in `echo $MOUNT` do mkdir $HFS/$i chown $OWN $HFS/$i chgrp $GROUP $HFS/$i chmod $PERM $HFS/$i mount -o rw $HFS/$i done # Backup the system for i in `echo $SRCFS` do echo $MINUSN "Dumping $i to ${HFS}/$i ...$BACKC" $DUMP 0f - $i | (cd ${HFS}/$i; $RESTORE rf -) done # Get rid of the restoresymtable file made by ufsrestore rm $HFS/restoresymtable for i in `echo $SFS` do rm $HFS/$i/restoresymtable done if [ "$OS" = "SunOS" ]; then # The disk wouldn't be much good if it didn't have a boot block. echo "Installing bootblk..." echo (cd /usr/sbin; ./installboot /usr/platform/sun4u/lib/fs/ufs/bootblk ${RDEV}/${BROOT}) fi # $FSTAB.bkp is a manually made file for booting # from the backup disks. It's probably handy to # have the standard vfstab laying around. echo "Change the $FSTAB, change default boot device" cp -p ${FSTAB}.bkp /broot/$FSTAB cp -p $FSTAB /broot/${FSTAB}.orig # Just a little paranoia, remount Read-Only so no accidents happen. # Great, SunOS can't remount to RO. if [ "$OS" = "SunOS" ]; then for i in `echo ${SFS}` do umount ${HFS}/$i done fi echo "Remounting backup filesystems Read-Only" for i in `echo $REMOUNT` do echo "mount $ROPT $HFS/$i" mount $ROPT $HFS/$i sleep 1 done if [ "$OS" = "FreeBSD" ]; then mount $ROPT $HFS fi echo date echo echo "Backup complete." echo if [ "$OS" = "SunOS" ]; then echo "In case of primary disk failure; Type "boot disk1" at the ok prompt." elif [ "$OS" = "FreeBSD" ]; then echo "In case of primary disk failure; type sd(1,a)/kernel at the boot: prompt." fi --ELM937233833-4549-0_ Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=online.dat Content-Description: /home/proot/online.dat Content-Transfer-Encoding: 7bit # Online backup data file for Horton # # This is the current fstab for Horton # # Device Mountpoint FStype Options Dump Pass# # /dev/sd0s1b none swap sw 0 0 # /dev/sd0s1a / ufs rw 1 1 # /dev/sd0s1f /usr ufs rw 2 2 # /dev/sd0s1g /usr/X11R6 ufs rw 2 2 # /dev/sd0s1h /usr/local ufs rw 2 2 # List of Filesystems export SLIST HLIST LIST SLIST="BACES BUSR BX11 BLOCAL" HLIST="BROOT" LIST="$HLIST $SLIST" # mount points export HFS SFS FS SRCFS HFS="/broot" SFS="usr/local usr/X11R6 usr" FS="$HFS $SFS" SRCFS="/ /usr /usr/local /usr/X11R6" # Mount Order export MOUNT REMOUNT MOUNT="usr usr/local usr/X11R6" REMOUNT="usr/local usr/X11R6 usr" # Map devices to logical names export BROOT BUSR BX11 BLOCAL BROOT='sd1s1a' BUSR='sd1s1f' BX11='sd1s1g' BLOCAL='sd1s1h' --ELM937233833-4549-0_-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message