From owner-freebsd-questions@FreeBSD.ORG Tue Sep 4 08:52:51 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26AC016A46B for ; Tue, 4 Sep 2007 08:52:51 +0000 (UTC) (envelope-from kris@FreeBSD.org) Received: from weak.local (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx1.freebsd.org (Postfix) with ESMTP id 6AE1213C49D; Tue, 4 Sep 2007 08:52:50 +0000 (UTC) (envelope-from kris@FreeBSD.org) Message-ID: <46DD1CE0.7000507@FreeBSD.org> Date: Tue, 04 Sep 2007 10:52:48 +0200 From: Kris Kennaway User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: Maikel Lambregts References: <20070904003709.9061313C45D@mx1.freebsd.org> In-Reply-To: <20070904003709.9061313C45D@mx1.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: problem with running mdconfig from shell 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: Tue, 04 Sep 2007 08:52:51 -0000 Maikel Lambregts wrote: > Hi, > > I want to make automatic backup of my MySQL by using FreeBSD snapshots. All > works fine when I run the commands from my Putty, but when I run them from a > shell script the 2th command (mdconfig) gives an error. > > These are the comments to make the backup, that work fine from Putty => > > ======================================== > /usr/local/bin/mysql -u??? -p??? -e "FLUSH TABLES WITH READ LOCK;system > mksnap_ffs /usr /usr/snapshot;UNLOCK TABLES;" > mdconfig -a -t vnode -f /usr/snapshot -u 4 > mount -r /dev/md4 /mnt > tar -cvjf /usr/home/mysqlsnapshot.tar.bz2 /mnt/home/databases > umount /mnt > mdconfig -d -u 4 > rm -f /usr/snapshot > ======================================== > > I get this error when I run the above from a .sh script => > > myserver# ./mysqlsnapshot.sh > : not found > mdconfig: bad unit: 4 > : No such file or directory This is not a mdconfig question, rather a basic shell scripting question. Use "sh -x" to run the script to see what it is doing wrong. One problem is that you are missing lots of error handling. If any of those commands fails then subsequent commands may misbehave. Kris