From owner-freebsd-questions@FreeBSD.ORG Wed Sep 21 02:27:09 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E450A16A41F for ; Wed, 21 Sep 2005 02:27:07 +0000 (GMT) (envelope-from lavalamp@spiritual-machines.org) Received: from mail.digitalfreaks.org (arbitor.digitalfreaks.org [216.151.95.158]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C7C543D46 for ; Wed, 21 Sep 2005 02:27:07 +0000 (GMT) (envelope-from lavalamp@spiritual-machines.org) Received: by mail.digitalfreaks.org (Postfix, from userid 1022) id C101B1141E; Tue, 20 Sep 2005 22:27:06 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.digitalfreaks.org (Postfix) with ESMTP id 879D41141B; Tue, 20 Sep 2005 22:27:06 -0400 (EDT) Date: Tue, 20 Sep 2005 22:27:05 -0400 (EDT) From: "Brian A. Seklecki" X-X-Sender: lavalamp@arbitor.digitalfreaks.org To: freebsd-questions@freebsd.org In-Reply-To: <20050920200555.B20769@arbitor.digitalfreaks.org> Message-ID: <20050920214827.M20769@arbitor.digitalfreaks.org> References: <20050920200555.B20769@arbitor.digitalfreaks.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: bseklecki@collaborativefusion.com Subject: 220.backup-bsdlabels (WAS: Re: periodic(8) / daily bsdlabel / fdisk / softraid*) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2005 02:27:09 -0000 Here's a basic script to accomplish this. No support for checking geom/gmirror/vinum configurations. RAIDFrame's raidctl(8) has a nice "-G" flag: "-G dev Generate the configuration of the RAIDframe device in a format suitable for use with the -c or -C options." Maybe someone more intimate with these 3 RAID APIs on FBSD can offer some insight. Obviously, this script will need to be re-written to do sanity checks especially with secure file operations. NetBSD has a nice function in /etc/security called migrate_file() {...} for safely rotating. And lines 42 and 44 are just ugly. Also, do non-i386/amd64 platforms support fdisk(8)? I know NetBSD uses sunlabel(8)+disklabel(8) on Sparc64? But this does what I need it to do. Given a solid off-site tape backup of /var, I can recover /var/backup/(fdisk|disklabel) to a temp machine, and recovery my slices. In the event of a complete system loss, I can use fdisk(8) output to verify that the number of sectors on my hardward or software RAID meta-device match as they were previously on the newly created RAID. PR is misc/86388! http://digitalfreaks.org/~lavalamp/220.backup-bsdlabels Thanks all! ~BAS --------- #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/220.backup-bsdlablels****** # # If there is a global system configuration file, suck it in. # if [ -r /etc/defaults/periodic.conf ] then . /etc/defaults/periodic.conf source_periodic_confs fi case "$daily_backup_bsdlabels_enable" in [Yy][Ee][Ss]) bak=/var/backups disks=`sysctl -n kern.disks` if [ -z "$disks" ]; then echo '$daily_backup_disklabels_enable" is set but no disk probed by kernel.' \ "perhaps NFS diskless client." rc = 2 else for i in $disks; do # first order of business is to check for an existing backup-backup if [ -f $bak/fdisk.$i.bak ] ; then rc=1 echo "rotating $bak/fdisk.$i.bak" cp -p $bak/fdisk.$i.bak $bak/fdisk.$i.bak2 || rc=3 fi echo "backing up fdisk for $i" fdisk $i > "$bak/fdisk.$i.bak" 2>/dev/null || rc=3 # again exept now we have to get a list of patitions/slices # sparc64 can have...9 hopefully slices on a sunlabel? part_slices=$(echo /dev/${i}s[0-9]) for j in $(echo "$part_slices" | sed 's/\/dev\///'); do if [ -f $bak/disklabel.${j}.bak ] ; then rc=1 echo "rotating $bak/disklabel.${j}.bak" cp -p $bak/disklabel.${j}.bak $bak/disklabel.${j}.bak2 || rc=3 fi echo "backing up disklabel for ${j}" disklabel /dev/${j} > "$bak/disklabel.${j}.bak" 2>/dev/null || rc=3 done done fi;; *) rc=0;; esac On Tue, 20 Sep 2005, Brian A. Seklecki wrote: > > All: > > I just realized that the stock perdiodic scripts dont backup fdisk/disklabel > output. I'm taken back a bit; NetBSD and OpenBSD have always done this > (archive to /var/backup). We backup the password and group files, but not > system info. > > Obviously, RAID can mitigate the need for this, but imagine a DRP scenario > where you have to recover a host to an offsite warm/cold failover facility > from off-site tape backups. You can get your vendor to provide identical > hardware, but without disk parition/slice info, how are you going to recover > your disks? > > It's bad enough we don't have a unified way to talk to RAID controllers > yet...the least we can do is try. > > We should probably also backup gmirror/gvinum config outputs... > > *sigh* > > ~BAS > l8* -lava x.25 - minix - bitnet - plan9 - 110 bps - ASR 33 - base8