Date: Mon, 29 Jan 2007 14:31:13 -0700 From: hal <hl700@cc.usu.edu> To: freebsd-questions@FreeBSD.ORG Subject: Re: Sorta OT - Backup solutions Mac to FreeBSD Message-ID: <65A04ADE-31EF-4B32-8DE7-E8D24906B8B5@cc.usu.edu> In-Reply-To: <20070129123502.836F.KEND@amigo.net> References: <20070126233731.673A316A419@hub.freebsd.org> <20070129123502.836F.KEND@amigo.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 29, 2007, at Monday, Jan29, 2007 12:45 PM, Kenny Dail wrote: >> I have been poking around the 'Net a bit looking for an easy to use >> backup solution for our Mac's (1 mini, 1 powerbook, more in the >> future). >> >> Basically there is a server, offsite (FBSD 6.2) with 2 RAID 5 arrays. >> I would like to be able to set the 2 (for now) clients to >> automatically, incrementally backup certain directories, nightly. >> Something encrypted would be nice aswell. Here is a script I run out of crontab on my Mac. Things to note: - Uses tar to create the backup. - Uses rcp to get the backup to the FreeBSD box. Could use scp if security is an issue. - It is a cshell script. - No software to find and install, everything you need is already on your Mac and freeBSD boxes. - I do a primary backup every night; no secondaries. - The script has been in production for about a year now and works flawlessly. - Restores are easy, just reverse the process. - I get an email daily giving me the status of the backup. - The tar file is written to /tmp before it is copied to the backup server so disk space could be an issue. - The tar file could be gziped (tar czf ) to save space at the expense of cpu time. - The log directory contains the status of the last two backups. - The backup server maintains 31 days of primaries. ######################################################################## ###### #!/bin/csh set LHOST=`hostname` set BASE=/backup_4/$LHOST set INFOPATH="/Users/root/dump_info" set RHOST=some.remote.host set RUSER=rmotuser set TARCMD="tar cf" set BKUP_DIR=/Users set SUCCESS_SUBJECT="$LHOST primary succeeded" set FAIL_SUBJECT="$LHOST primary failed" set MAIL_TO="myname@my.mail.server" set SEQFILE=$INFOPATH/Sequence echo "*** `date` $LHOST Begin setup for this primary backup" echo "*** `date` Set sequence number of this dump" if(-s $SEQFILE) then set LAST=`cat $SEQFILE` else echo "WARNING: $SEQFILE non-existant or 0 size" echo " Set last sequence to 0" set LAST="0" endif echo "*** `date` Last sequence number used: $LAST" switch($LAST) case "0": set SEQ="1" breaksw case "1": set SEQ="0" breaksw default: echo "WARNING: Dump sequence is invalid: $LAST" echo " Set dump sequence to 0" set SEQ="0" breaksw endsw echo "*** `date` Sequence number of this dump is: $SEQ" echo "*** `date` Set path variables" set INFO=$INFOPATH/primary.$SEQ set FILE=Users_$SEQ.tar set RFILE=$RUSER@$RHOST\:$BASE/$FILE set TMPFILE=/var/tmp/$FILE echo "Path to backup: $BKUP_DIR" echo "Log file......: $INFO" echo "Temporary file: $TMPFILE" echo "Remote file...: $RFILE" echo "*** `date` $LHOST Setup for this primary backup complete" echo "*** `date` $LHOST primary backup begun" >& $INFO echo "*** `date` Sequence number of this dump is: $SEQ" >>& $INFO echo "*** `date` get space used in $BKUP_DIR" >>& $INFO du -hs $BKUP_DIR/* >>& $INFO echo "*** `date` tar $BKUP_DIR to $TMPFILE" >>& $INFO $TARCMD $TMPFILE $BKUP_DIR >>& $INFO set rslt=$status if($rslt != 0) then echo "FATAL: tar failed, status=$rslt" >>& $INFO set subject="$FAIL_SUBJECT" goto pgm_exit endif echo "*** `date` Check size of $TMPFILE" >>& $INFO ls -l $TMPFILE >>& $INFO echo "*** `date` rcp $TMPFILE to $RFILE" >>& $INFO rcp $TMPFILE $RFILE >>& $INFO set rslt=$status if($rslt != 0) then echo "FATAL: rcp failed, status=$rslt" >>& $INFO set subject="$FAIL_SUBJECT" goto pgm_exit endif echo "*** `date` rm $TMPFILE" >>& $INFO rm $TMPFILE >>& $INFO set rslt=$status if($rslt != 0) then echo "FATAL: rm failed, status=$rslt" >>& $INFO set subject="$FAIL_SUBJECT" goto pgm_exit endif set subject="$SUCCESS_SUBJECT" echo "*** `date` Record sequence number of this dump" >>& $INFO echo "$SEQ" > $SEQFILE pgm_exit: echo "*** `date` Exit status=$subject" >>& $INFO echo "*** `date` $LHOST primary backup ended" >>& $INFO mail -s "$subject" $MAIL_TO < $INFO exit 0 ######################################################################## ###
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?65A04ADE-31EF-4B32-8DE7-E8D24906B8B5>