Date: Sun, 18 Jan 2009 15:33:30 +0100 (CET) From: Alexander Best <alexbestms@math.uni-muenster.de> To: <freebsd-current@freebsd.org> Subject: periodic(8) daily should backup bsdlabel(8) / fdisk(8) disk labels Message-ID: <permail-200901181433301e86ffa8000037a6-a_best01@message-id.uni-muenster.de>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] hi there, i was browsing the pr-db and found this pr: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/86388 i think it would be a very nice addition to daily. i attached 220.backup-bsdlabels. it can also be found here: http://digitalfreaks.org/~lavalamp/220.backup-bsdlabels backing up the disk labels on a daily basis sounds like a really good thing to do. also the pr states that netbsd and openbsd are doing this for over 10 years now. cheers. alex [-- Attachment #2 --] #!/bin/sh # # $FreeBSD: src/etc/periodic/daily/220.backup-bsdlablels****** # # $Id: 220.backup-bsdlabels 36 2006-06-12 21:50:35Z seklecki $ # Ripped right out NetBSD /etc/daily. Backup FDISK MBR and BSD # Disklabel data to local filesystem to be picked up by periodic # offsite data recovery/storage mechanism (Bacula, Amanda, pax(1)) # to simplify recovery to identical geometry hardware at secondary/ # backup datacenter ~BAS # 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 # test debug # disks="ad0" disks=$(sysctl -n kern.disks); if [ -n "$daily_backup_bsdlabels_include" ]; then #daily_backup_bsdlabels_include=$(echo ${daily_backup_bsdlabels_include}|sed -e "s/\//\_/g") disks="${disks} ${daily_backup_bsdlabels_include}" fi if [ -n "$daily_backup_bsdlabels_exclude" ]; then disks=$(echo ${disks} | sed -e "s/${daily_backup_bsdlabels_exclude}//g") fi if [ -z "$disks" ]; then echo '$daily_backup_disklabels_enable" is set but no disk probed by kernel.' \ "perhaps NFS diskless client." rc = 2 else echo "Backing up device MBR and BSD labels for: ${disks}"; 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 -pf ${bak}/fdisk.${i}.bak $bak/fdisk.${i}.bak2 || rc=3 fi echo "backing up fdisk for ${i}" fdisk ${i} > "${bak}/$(echo "fdisk.${i}.bak"| sed -e "s/\//\_/g")" 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 -fp ${bak}/disklabel.${j}.bak ${bak}/disklabel.${j}.bak2 || rc=3 fi echo "backing up disklabel for ${j}" disklabel /dev/${j} > "${bak}/$(echo "disklabel.${j}.bak"|sed -e "s/\//\_/g")" 2>/dev/null || rc=3 done done fi;; *) rc=0;; esac exit $rc
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-200901181433301e86ffa8000037a6-a_best01>
