From owner-freebsd-questions@FreeBSD.ORG Sat Mar 3 09:56:19 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 819DD16A400 for ; Sat, 3 Mar 2007 09:56:19 +0000 (UTC) (envelope-from mplekos@physics.upatras.gr) Received: from nic.upatras.gr (nic.upatras.gr [150.140.129.30]) by mx1.freebsd.org (Postfix) with SMTP id AF1B313C441 for ; Sat, 3 Mar 2007 09:56:18 +0000 (UTC) (envelope-from mplekos@physics.upatras.gr) Received: (qmail 4447 invoked by uid 111); 3 Mar 2007 09:29:35 -0000 Received: from 150.140.159.71 by nic.upatras.gr (envelope-from , uid 103) with qmail-scanner-1.25 (clamdscan: 0.83/706. Clear:RC:1(150.140.159.71):. Processed in 0.073681 secs); 03 Mar 2007 09:29:35 -0000 Received: from pythagoras.physics.upatras.gr (150.140.159.71) by nic.upatras.gr with SMTP; 3 Mar 2007 09:29:35 -0000 Received: (qmail 26790 invoked by uid 1111); 3 Mar 2007 09:26:47 -0000 Date: Sat, 3 Mar 2007 11:26:47 +0200 From: Kostas Blekos To: Robert Davison Message-ID: <20070303092646.GA26572@pythagoras.physics.upatras.gr> Mail-Followup-To: Robert Davison , freebsd-questions@freebsd.org References: <285897.32858.qm@web25012.mail.ukl.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <285897.32858.qm@web25012.mail.ukl.yahoo.com> User-Agent: Mutt/1.4.2.2i Cc: freebsd-questions@freebsd.org Subject: Re: Backup Script 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: Sat, 03 Mar 2007 09:56:19 -0000 Robert Davison on Sat, Mar 03, 2007 (09:06 +0000) wrote: > Im trying to write a small backup script which I have put in > /etc/periodic/weekly. The script is as follows...... > > #!/bin/sh > # > #weekly backup of chosen files > # > if > then > tar -cf /dev/sa0 /var/ftp /home /etc /usr/local > echo "backing up the disks" > else > echo "There was a problem" 1>&2 > exit 1 > fi > echo "Finished at `/bin/date`." > exit > > > Now I have no experience at bash scripting as was wonderng if > someone could give me some help with the if statement. Basically im > trying to test to see if the machine knows that /dev/sa0 (my tape > drive) is accessable. If it is then it continus to the backup, if > not then it gives the error message and echos the date. > > Any help would be much appreciated. > > > You can test if it is writable by: [ -w /dev/sa0 ] eg: ----------- if [ -w /dev/sa0 ] then echo "Writable" else echo "Not writable" fi ----------- "man test" for other tests. -- Kostas Blekos GPGKey = 1398 1AB3 483E B2DF 3A2D 95F4 7534 E392 012E 6167