From owner-freebsd-questions@FreeBSD.ORG Mon Jul 9 20:43:53 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 62FB416A41F for ; Mon, 9 Jul 2007 20:43:53 +0000 (UTC) (envelope-from xrayv19@yahoo.com) Received: from web58108.mail.re3.yahoo.com (web58108.mail.re3.yahoo.com [68.142.236.131]) by mx1.freebsd.org (Postfix) with SMTP id 287BE13C468 for ; Mon, 9 Jul 2007 20:43:53 +0000 (UTC) (envelope-from xrayv19@yahoo.com) Received: (qmail 30627 invoked by uid 60001); 9 Jul 2007 20:43:52 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=Kanqn20vbW7kxrKv/zl5RSa8DKn/5zcCtGiaV7jyZCCWYhHCFAkx1az/wGp+HNxH4qIHybIs0MIqI6EM1lMMtV7qwT8Lg5Ufdwf5xzkzsSFPR3EHhx2g6CCOiPUKeLeXDt62Wgk+YLLLaE3puWBcftbbzcZqLUqID6j7aJTYn4A=; X-YMail-OSG: zICc0fkVM1mKokK.k_LYdFHQMC_vtiAwR5ohLF0sHR_uIrHaL8KRXH8755yVj2QaNsQukwFu6grC3qf_Q86zVGIyYvov0nA2BH.LqUhYIxbyJGnXaLO0rg-- Received: from [131.191.24.2] by web58108.mail.re3.yahoo.com via HTTP; Mon, 09 Jul 2007 13:43:52 PDT Date: Mon, 9 Jul 2007 13:43:52 -0700 (PDT) From: L Goodwin To: Roland Smith In-Reply-To: <20070708080431.GA17250@slackbox.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <396655.30624.qm@web58108.mail.re3.yahoo.com> Cc: freebsd-questions@freebsd.org Subject: Re: Correct way to use dump to backup a Samba share 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, 09 Jul 2007 20:43:53 -0000 Thanks for filling in the blanks, Roland! --- Roland Smith wrote: > On Sat, Jul 07, 2007 at 06:42:20PM -0700, L Goodwin > wrote: > > I have a Samba share on a software RAID 1 array > (using > > gmirror) that I need to backup. I want to create a > > shell script that does a level 0 backup every time > to > > (alternately) one of two USB drives. I plan to > have > > only ONE USB drive connected at a time. > > > > I want the script to mount the drive, perform the > > backup, then unmount the drive so that it is ready > for > > someone who knows zip about computers to safely > remove > > and take offsite. > > > > Here are the steps I have for the script. > > Is this all I need to do? Do I need any error > handling > > logic? THANKS! > > > # Mount the backup drive: > > mount /dev/usb0 > > > > # Create the backup: > > /sbin/dump -0u -f /dev/usb0 /sambavol > > > > # Unmount the backup drive: > > umount /dev/usb0 > > The following is a rough outline of what you should > do; > -------------- shell-script -------------- > #!/bin/sh > # The following assumes that the USB mass-storage > device is formatted > # with a UFS filesystem > > # Only root can perform dumps. > if [ $(id -u) -ne 0 ]; then > echo "Only root can perform dumps. Exiting." > exit 1 > fi > > DDIR=/mnt/root > # First, check if the target directory exists > if [ ! -d $DDIR ]; then > echo "The $DDIR directory doesn't exist. > Exiting." > exit 1 > fi > # Then check if it is already mounted > if mount|grep $DDDIR >/dev/null; then > echo "The $DDIR directory is already in use. > Exiting" > exit 1 > fi > > # Check if the device to dump to exists; > DEV=/dev/da0 > if [ ! -c $DEV ]; then > echo "The $DEV device doesn't exist. Exiting." > exit 1 > fi > # Check if the device is already mounted > if mount|grep $DEV >/dev/null; then > echo "The $DEV device is already mounted. > Exiting" > exit 1 > fi > > SRC=/sambavol > DFLAGS="-0 -u -f" > # Check if the filesystem that is to be dumped > exists. > if [ ! -d $SRC ]; then > echo "The $SRC directory doesn't exist. > Exiting." > exit 1 > fi > # Now check if it is mounted > if mount -t ufs|grep $SRC; then > DFLAGS="-L "$DFLAGS > fi > > # Mount the USB device. > if ! mount $DEV $DDIR; then > "Mounting the USB disk failed. Exiting" > exit 1 > fi > > DATE=$(date "+%Y%m%d") > # Perfrom the dump, assuming that the filesystem is > live. > dump $DFLAGS ${DDIR}/sambavol-0-${DATE}.dump $SRC > > umount $DDIR > -------------- shell-script -------------- > > Of course, you have to remove old dumps once in a > while, lest you run > out of disk space. > > Depending on the contents of the samba share, it > might be worthwhile to > compress the dump with gzip; > > # Perfrom the dump, > dump $DFLAGS - $SRC|gzip > >${DDIR}/sambavol-0-${DATE}.gz > > Roland > -- > R.F.Smith > http://www.xs4all.nl/~rsmith/ > [plain text _non-HTML_ PGP/GnuPG encrypted/signed > email much appreciated] > pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 > A725 (KeyID: C321A725) > ____________________________________________________________________________________ Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. http://autos.yahoo.com/green_center/