Date: Mon, 6 May 2002 17:26:01 -0400 From: Rob Ellis <rob@web.ca> To: Steve Bertrand <steve@echelonmedia.com> Cc: freebsd-questions@freebsd.org Subject: Re: Backup script.. Message-ID: <20020506212601.GC94937@web.ca> In-Reply-To: <POEIKDACFKKMEPHGPJLMGEHOCAAA.steve@echelonmedia.com> References: <POEIKDACFKKMEPHGPJLMGEHOCAAA.steve@echelonmedia.com>
next in thread | previous in thread | raw e-mail | index | archive | help
For checking equivalence of numbers in a shell script use '-eq' or '-ne': if [ "$size1" -eq "$size2" ]; then... For what you're doing you could use diff instead of du, like diff -r --brief /path/to/backup /path/to/live/dir >/dev/null if [ $? -ne 0 ]; then # they differ, do something fi $? is the result code from the last command. Or maybe use rsync (/usr/ports/net/rsync) ? - Rob On Mon, May 06, 2002 at 03:21:17PM -0400, Steve Bertrand wrote: > I spent all weekend documenting and securing my network which contains 3 > FreeBSD servers. My internal network server which is a PDC running Samba is > being used as a central backup controller. I have written crontabs for all > of the BSD servers to collect all critical config files and store them in a > backup directory for the backup controller to collect later using scp for > dumping to tape. > > Although I have been able to automate 90% of this operation, I would like to > have each server check to see if the directory containing it's backup has > changed since the previous backup 24 hours earlier, if not, skip the backup. > I am off site right now, so this may not be exactly what I was working with, > and this is not my entire backup script, just the test section for comparing > sizes > > ####################### > #`snip from backup script //testing only > #!/bin/sh > > size1=`du -s /tmp/svr3bkp` > size2=`du -s /path/to/live/dir` > overall='$size1 = $size2' /* am I using the proper 'equal to' operand here? > */ > > if ! [ $overall] > then > dosomething > else > dosomethingelse > fi > > ################## > > I get an error to the effect of 'Command not found' or similar. > Am I on the right track? I used to do some C++ programming and find this to > be very similar, but I still need to get used to some of the operators and > how to implement commands into the script. As far as I remember, == would > be the 'equal to' operand, but I can't find documentation to state > otherwise. > > Are there commands used to test the differences in file/dir sizes or mod > dates that I can use as a conditional to perform other commands? > > Tks, > > Steve > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020506212601.GC94937>