From owner-freebsd-questions@FreeBSD.ORG Wed Jan 16 15:43:01 2008 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 DB1A116A417 for ; Wed, 16 Jan 2008 15:43:01 +0000 (UTC) (envelope-from wodfer@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.176]) by mx1.freebsd.org (Postfix) with ESMTP id 8E81613C459 for ; Wed, 16 Jan 2008 15:43:01 +0000 (UTC) (envelope-from wodfer@gmail.com) Received: by py-out-1112.google.com with SMTP id u52so440682pyb.10 for ; Wed, 16 Jan 2008 07:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=DE7ffa0x6oWFi2tweECf/M9bimXWPR8Vx8WR/qhpJMo=; b=gza4FakKC1R4Z9TcuwvQekUU7TuokJT7CVQzgO1k0CP5Fk09CSxa52PufaD/B9jO+YwXpTlU+Ad4OzTQQejHSodk3cO3/KrWGTbGHDATR7EOXMq9plSei9vsU+wjye4Jvl69fom+70Dr67WxdSc8QCf+hKaAQfifqsjBLxHSIIc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=QHdOQODgzbXWrlTxsdXHP/OQ0dZJ2xE74lC2NAZoXYo7Z3q8vT/L+5of13sGyf6O2+rmWq+Kd75Tbhjwer0agStGCuWeB2r5u2oeN5XXpwwVbxmw/130jdQjMwCSnwTWUAxDqnpvdulqEaAifppXURS6n7DyJ5LicsfjVL487rs= Received: by 10.141.18.14 with SMTP id v14mr604854rvi.252.1200496437046; Wed, 16 Jan 2008 07:13:57 -0800 (PST) Received: by 10.141.87.7 with HTTP; Wed, 16 Jan 2008 07:13:57 -0800 (PST) Message-ID: <23ed14b80801160713q10606d2es21e869f935b22257@mail.gmail.com> Date: Wed, 16 Jan 2008 16:13:57 +0100 From: "=?ISO-8859-1?Q?Andreas_Wider=F8e_Andersen?=" To: "Valerio Daelli" In-Reply-To: <27dbfc8c0711210555h1a862f5drccb1a6f5bcb1a837@mail.gmail.com> MIME-Version: 1.0 References: <23ed14b80711210539w4bed1enc180f8e32ec76881@mail.gmail.com> <27dbfc8c0711210555h1a862f5drccb1a6f5bcb1a837@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions Subject: Re: Need help with backup 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: Wed, 16 Jan 2008 15:43:01 -0000 On Nov 21, 2007 2:55 PM, Valerio Daelli wrote: > On Nov 21, 2007 2:39 PM, Andreas Wider=F8e Andersen > wrote: > > Hi, > > > > I'm working on a shell script that will let me attach (mount) an > > external USB 2.0 harddrive and to my FreeBSD 6.2 server and perform a > > full backup of /backup on my server (all files and subfolders) once or > > twice a week (whenever I run the cronjob). The script must be able to > > run through a cronjob and the drive must be mounted and unmounted > > after each job (I will swap between two drives of the same type and > > size). The script must also remove folders/files older than 30 days. > > > > Does anyone use a script like this today that they can share? I'm not > > a shell scripter myself so any help is highly appreciated. > > > > Here's my rough idea/sketch: > > > > #! /bin/sh > > > > $MOUNT =3D /external > > $DATE=3D date_today > > > > mount usb_drive $MOUNT > > cd /$MOUNT > > rm all files forlders older than 30 days > > mkdir /$DATE > > cp -fr /backup to /$MOUNT/$DATE > > cd > > unmount > > > > > --- > #!/bin/sh > > MOUNT=3D/external > DATE=3D`date +%Y%m%d%H%M` > > mount /dev/da2 $MOUNT #Change device name > find $MOUNT -mtime +30 -delete > mkdir $MOUNT/$DATE > cp -rp /backup/* $MOUNT/$DATE > umount /external > --- > > Bye > > Valerio Daelli > Hi again and thanks for the replies to my question. I have finally rebuilt world and compiled a new kernel since I didn't have USB support and SCSI/da support in my previous kernel. I have also used you= r suggestion and created this script that I can run from command line or as a cronjob: #!/bin/sh MOUNT=3D/external DATE=3D`date +%Y%m%d%H%M` mount /dev/da0 $MOUNT #Change device name find $MOUNT -mtime +30 -delete mkdir $MOUNT/$DATE rsync -rlpgoD /backup/ $MOUNT/$DATE umount /external dmesg shows: umass0: Generic USB Storage Device, rev 2.00/0.00, addr 2 umass0: Get Max Lun not supported (TIMEOUT) da0 at umass-sim0 bus 0 target 0 lun 0 da0: Fixed Direct Access SCSI-2 device da0: 1.000MB/s transfers da0: 476940MB (976773168 512 byte sectors: 255H 63S/T 60801C) When I try to run my script I get this prompt back: mount: /dev/da0 on /external: incorrect super block (allthough the script seems to continue to run). Am I doing something wrong here or do I need to I need to use one of the other from /dev: ls -la /dev [snip] crw-r----- 1 root operator 0, 92 Jan 12 03:42 da0 crw-r----- 1 root operator 0, 93 Jan 12 03:28 da0s1 crw-r----- 1 root operator 0, 98 Jan 12 03:28 da0s1c crw-r----- 1 root operator 0, 99 Jan 12 03:28 da0s1d Thanks for any help here! Best regards, Andreas