From owner-freebsd-questions@FreeBSD.ORG Mon Jan 29 21:31:14 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 57BD216A400 for ; Mon, 29 Jan 2007 21:31:14 +0000 (UTC) (envelope-from hl700@cc.usu.edu) Received: from ironport1.usu.edu (ironport1.usu.edu [129.123.1.26]) by mx1.freebsd.org (Postfix) with ESMTP id 3136C13C49D for ; Mon, 29 Jan 2007 21:31:14 +0000 (UTC) (envelope-from hl700@cc.usu.edu) Received: from buffy.ncs.usu.edu (HELO [129.123.104.140]) ([129.123.104.140]) by ironport1.usu.edu with ESMTP; 29 Jan 2007 14:31:13 -0700 X-SBRS: None X-IronPort-AV: i="4.13,253,1167634800"; d="scan'208"; a="21775744:sNHT15813798" Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: <20070129123502.836F.KEND@amigo.net> References: <20070126233731.673A316A419@hub.freebsd.org> <20070129123502.836F.KEND@amigo.net> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <65A04ADE-31EF-4B32-8DE7-E8D24906B8B5@cc.usu.edu> Content-Transfer-Encoding: 7bit From: hal Date: Mon, 29 Jan 2007 14:31:13 -0700 To: freebsd-questions@FreeBSD.ORG X-Mailer: Apple Mail (2.752.2) Cc: Subject: Re: Sorta OT - Backup solutions Mac to FreeBSD 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: Mon, 29 Jan 2007 21:31:14 -0000 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 ######################################################################## ###