From owner-freebsd-questions@FreeBSD.ORG Thu Nov 11 18:09:31 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E10F16A4CE for ; Thu, 11 Nov 2004 18:09:31 +0000 (GMT) Received: from crumpet.united-ware.com (ddsl-66-42-172-210.fuse.net [66.42.172.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id 07DE543D46 for ; Thu, 11 Nov 2004 18:09:31 +0000 (GMT) (envelope-from mistry.7@osu.edu) Received: from [192.168.0.5] (adsl-68-250-184-205.dsl.wotnoh.ameritech.net [68.250.184.205]) (authenticated bits=0)iABHoUUJ041934 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Thu, 11 Nov 2004 12:50:34 -0500 (EST) (envelope-from mistry.7@osu.edu) From: Anish Mistry To: Odhiambo Washington Date: Thu, 11 Nov 2004 13:11:55 -0500 User-Agent: KMail/1.7 References: <20041109133932.GB41233@ns2.wananchi.com> <200411091923.30281.mistry.7@osu.edu> <20041111164524.GA96388@ns2.wananchi.com> In-Reply-To: <20041111164524.GA96388@ns2.wananchi.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2919069.4yIbZ8gUqv"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200411111312.11301.mistry.7@osu.edu> X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.64 X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on crumpet.united-ware.com cc: freebsd-questions@freebsd.org Subject: Re: Nightly backup using CD-ROM - how do i? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Nov 2004 18:09:31 -0000 --nextPart2919069.4yIbZ8gUqv Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 11 November 2004 11:45 am, you wrote: > * Anish Mistry [20041110 03:21]: wrote: > > [snip] > > Hey Anish, > > Thank you so much for your script. > > I am not quite a newbie on Unix, but your script has gotten me lost, > such that I feel like a newbie ;) > > Could you kindly explain to me, step-by-step, how it works, please? > > > #!/bin/sh > > # the date > > DATESTRING=3D`date +"%Y%m%d"` > > BACKUP_DIR=3D/usr/local/var/backup > > CD_DEVICE=3D/dev/acd0c > > Defining the date of the backups to copy, it assumes the current. Set the= =20 directory where the already tar'ed files are locations, and also set the=20 CDROM device. > > # first check if there is enough space left on device > > # mount > > #/sbin/mount /cdrom > > #CD_SIZE=3D700 > > #CD_FILL=3D`/usr/bin/du /cdrom | /usr/bin/cut -f 1` > > # unmount > > #/sbin/umount /cdrom > > This is just commented out since it I ended up no needing it. > > cd $BACKUP_DIR > > # get previous multisession info > > MSINFO=3D`/usr/sbin/burncd -f $CD_DEVICE msinfo` > > if [ "$MSINFO" !=3D "" ] > > then > > MULTISESSION=3D"-C $MSINFO -M $CD_DEVICE" > > else > > echo "First session." > > fi Here we probe the CD to get the last session's track info. If there is not= =20 last session info, then that means that it's a blank cd so we don't add=20 the multisession info to the mkisofs command. > > # create the .iso > > echo "Creating backup ISO..." > > /usr/local/bin/mkisofs -r -J -quiet $MULTISESSION -o > > $BACKUP_DIR/$DATESTRING.iso $BACKUP_DIR/$DATESTRING*.tar.gz # burn > > backups to cd We create an ISO offset with multisession info if available with the files= =20 in the backup directory that match the date string. > > echo "Burning backups to $CD_DEVICE..." > > /usr/sbin/burncd -f $CD_DEVICE -q -s 24 -m data > > $BACKUP_DIR/$DATESTRING.iso fixate if [ $? -ne 0 ] > > then > > echo "Sysadmin, I\'m sorry the backup failed." | /usr/bin/mail -s > > "The sky is falling!" someemail@fake.com fi We burn the iso to the CD, it the command returns non-zero then it goes=20 into the if statement and sends off and email tell someone to change the=20 CD. > > # delete the .iso > > echo "Deleting ISO..." > > rm $BACKUP_DIR/$DATESTRING.iso > > echo "Done." > > exit 0 Cleanup and exit. Hope that helps. =2D-=20 Anish Mistry --nextPart2919069.4yIbZ8gUqv Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQBBk6t7xqA5ziudZT0RAvA2AKC1/4UbEb1V0x/uWE6eeB+jyXgCGQCgskIT hSzk/BtNBcTKLbkmBYSzH7s= =1fJI -----END PGP SIGNATURE----- --nextPart2919069.4yIbZ8gUqv--