On Mon, Jul 19, 2010 at 08:31:11PM -0500, Sam Fourman Jr. wrote:
> On Mon, Jul 19, 2010 at 7:37 PM, Alexander Best <arun...@freebsd.org> wrote:
> > how about adding a periodic script to /etc/periodic/daily to backup the 
> > information?
> >
> > the idea was raised a long time ago already, but was abandoned [1].
> >
> > cheers.
> > alex
> >
> 
> I think that is a good idea, if you have a script to do that I would test it

ok here's a dirty dirty patch.

what i did was take the etc/periodic/daily/210.backup-aliases script and do 
some hacking. this is the work of 2 minutes or so. that's why the script is 
pretty crappy and probably plain wrong in a few cases.

however somebody else who has more time might be able to improve it. :)

changes to etc/defaults/periodic.conf and etc/periodic/daily/Makefile (or where 
you want the script to go) need to be hacked in by hand.

cheers.
alex
> 
> 
> -- 
> 
> Sam Fourman Jr.
> Fourman Networks
> http://www.fourmannetworks.com
--- /dev/null   2010-07-22 20:33:01.000000000 +0200
+++ etc/periodic/daily/220.backup-geom  2010-07-22 20:09:13.000000000 +0200
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# $FreeBSD:$
+#
+
+# 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_gpart_enable" in
+    [Yy][Ee][Ss])
+       temp=/tmp/gpart_temp.bak
+       gpart show > $temp
+       if [ ! -s $temp ]
+       then
+           echo "nothing to backup"
+           rm $temp || rc=2
+       else
+           bak=/var/backups
+           rc=0
+
+           echo ""
+           echo "Backing up geom partition information:"
+
+           if [ ! -f $bak/gpart.bak ]
+           then
+               echo "no $bak/gpart.bak"
+               mv $temp $bak/gpart.bak || rc=3
+
+           elif ! cmp -s $bak/gpart.bak $temp
+           then
+               [ $rc -lt 1 ] && rc=1
+               echo "geom partition layout has been altered:"
+               diff -u $bak/gpart.bak $temp
+               mv $bak/gpart.bak $bak/gpart.bak2
+               mv $temp $bak/gpart.bak || rc=3
+           else
+               echo "geom partition layout hasn't been altered. skipping 
backup."
+           fi
+       fi;;
+
+    *)  rc=0;;
+esac
+
+exit $rc
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to