From owner-freebsd-questions@FreeBSD.ORG Thu May 26 08:58:28 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 C86AD16A420 for ; Thu, 26 May 2005 08:58:27 +0000 (GMT) (envelope-from steve@lonres.com) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7665743D1D for ; Thu, 26 May 2005 08:58:27 +0000 (GMT) (envelope-from steve@lonres.com) Received: from mail.lonres.com ([194.70.153.187]) by anchor-post-35.mail.demon.net with esmtp (Exim 4.42) id 1DbE8l-0007zd-GA for freebsd-questions@freebsd.org; Thu, 26 May 2005 08:54:55 +0000 Received: from bibipentium.lonres.com (bibipentium.lonres.com [10.10.10.225]) by mail.lonres.com (Postfix) with SMTP id DCC592E0A3 for ; Thu, 26 May 2005 09:58:23 +0100 (BST) Received: by bibipentium.lonres.com (sSMTP sendmail emulation); Thu, 26 May 2005 09:58:47 +0100 From: "Steve Roome" Date: Thu, 26 May 2005 09:58:47 +0100 To: freebsd-questions@freebsd.org Message-ID: <20050526085847.GA16434@bibipentium.lonres.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: snapshot mtime updated 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: Thu, 26 May 2005 08:58:30 -0000 I asked this yesterday, but the attachment had been stripped out, stuck it on the end of the email this time. Should I be asking this on some other mailing list ? -- original message: Hi all, I've got a problem where I'm taking a snapshot of a filesystem, mdcofigging (readonly) and then mounting it ro,noatime. Somehow the mtime on the snapshot file is being updated whenever I read from the newly mounted md device (pointing at the snapshot). This doesn't seem right, and I've included the script I'm using to do this. I'm not really interested in ways to fix this script, though there are probably many better ways to do this, right now I'm just unsure if this is the correct behavious for snapshots. Thanks in advance if anyone knows what's going on here, Steve Roome P.S. I'm not subscribed to the mailing list, please cc responses to me. dodgy snapshot/remount/tar up script. ------------------------------------------------------------------------ #!/bin/sh # Copyright Steve Roome. You can do what you like with this code, I'd # suggest that you delete it. If you want to run it use: # ./whateverthisis.sh SNAPMOUNT="/backup_mnt" die() { echo $* exit 1 } MOUNT=$1 MYUID=`id -u` [ $MYUID -eq "0" ] || die "You are not root, you will need to be root to mount the snapshot" # Check that this is a UFS2 mount point /sbin/mount -p -t ufs | /usr/bin/awk '{print $2}' | grep -cx ${MOUNT} 2>&1 >/dev/null || die "$MOUNT is not a mounted ufs filesystem" BACKUP_DIR=${MOUNT}/hourly_snaps # Check that BACKUP_DIR exists and is writable SNAPDIR=$MOUNT/.snap [ -d $SNAPDIR ] || mkdir $SNAPDIR || die "Can't create $SNAPDIR" SNAPBASE=${SNAPDIR}/`/bin/date "+%Y.%m.%d.%H:%M"` SNAPFILE=${SNAPBASE}.snap SNAPMOUNT="/backup_mnt" SNAPTGZ=${SNAPBASE}.tgz TEMPTGZ=${SNAPBASE}.temp START_PWD=`pwd` #echo "Snapshots will be saved in ${SNAPDIR}" #echo "The next snapshot will be named ${SNAPFILE}" #echo "The snapshot will be mounted on ${SNAPMOUNT}" #echo "${SNAPMOUNT} will be tgz'ed to ${SNAPTGZ}" touch ${SNAPFILE} > /dev/null 2>&1 && rm ${SNAPFILE} || die "Can't save snapshot in $SNAPFILE" touch ${TEMPTGZ} > /dev/null 2>&1 && rm ${TEMPTGZ} || die "Can't save snapshot in $SNAPFILE" [ -d $SNAPMOUNT ] || mkdir $SNAPMOUNT || die "Can't create mount point $SNAPMOUNT" # Check that SNAPFILE can be created/deleted mksnap_ffs $MOUNT $SNAPFILE && MD_DEV=`mdconfig -a -t vnode -f $SNAPFILE` && mount -o ro,noatime /dev/$MD_DEV /${SNAPMOUNT} cd ${SNAPMOUNT} && tar -czp --exclude .snap/ -f ${TEMPTGZ} . 2>/dev/null || die "Failed to create tarfile: ${TEMPTGZ} PLEASE INVESTIGATE" cd ${START_PWD} umount ${SNAPMOUNT} MD_UNIT=`echo $MD_DEV | sed -e 's/^md//g'` mdconfig -d -u ${MD_UNIT} && rm -f ${SNAPFILE} && rmdir ${SNAPMOUNT} && mv ${TEMPTGZ} ${SNAPTGZ} && echo "${SNAPTGZ} ceated successfully from snapshot of ${MOUNT}" || die "Did not manage to clear up after backing up ${MOUNT}\nIntervention recommended" # finished okay! exit 0