From owner-freebsd-questions@FreeBSD.ORG Sun Mar 19 21:55:20 2006 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 1834F16A4C8 for ; Sun, 19 Mar 2006 21:55:20 +0000 (UTC) (envelope-from pergesu@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id A3ECC43D46 for ; Sun, 19 Mar 2006 21:55:19 +0000 (GMT) (envelope-from pergesu@gmail.com) Received: by zproxy.gmail.com with SMTP id m7so1327407nzf for ; Sun, 19 Mar 2006 13:55:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=jy8dScRnoiEOmQZyEMs6i7go3uRQf4Mzp20DmQ3DnfZpDMmFmdkBBWkuoyNzAJtutSlpyy54Lv/v1N0jZFZYWiUQ0zHEFXQxSMe0bLthgGtaDOMCtzyW6DRXR2ZB04kgRskScJHELpZirleqP82i8DsTMWEX42VAP7XwAL+f/Cc= Received: by 10.36.106.13 with SMTP id e13mr273041nzc; Sun, 19 Mar 2006 13:55:18 -0800 (PST) Received: by 10.36.50.5 with HTTP; Sun, 19 Mar 2006 13:55:18 -0800 (PST) Message-ID: <810a540e0603191355n3e86fe15pa15a24da1a48dce8@mail.gmail.com> Date: Sun, 19 Mar 2006 14:55:18 -0700 From: "Pat Maddox" To: "FreeBSD Questions" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: rsync script not excluding dirs 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: Sun, 19 Mar 2006 21:55:20 -0000 I have a backup script that runs nightly, and I want it to exclude certain dirs (ports, obj, etc). However when I run the script it doesn't exclude anything, leaving me with pretty massive backups.=20 Here's the entire script. /, /var, /usr, and /backup are all on different partitions. The key part is at the bottom where it calls rsync and excludes dirs. Can someone tell me what's wrong with the script? Pat #!/bin/sh HOME=3D/ PATH=3D/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export HOME PATH STAGE DAY MONTH YEAR DAY2 DAY1 PERMS SVR PRE ARG PERMS=3D`date +%Y%m%d` SVR=3D"cantona" # forward dating DAY1=3D`date +%Y/${SVR}/%m/%d` # reverse dating for removal of old backup DAY2=3D`date -j -v-1w +%Y/${SVR}/%m/%d` PRE=3D"/usr/local/bin/rsync" ARG=3D`ps -ax | grep ${PRE} | grep -v grep | wc -l | awk '{ print $1 }'` if [ $ARG -gt 0 ]; then echo "$PRE is running" return $? fi # Remount the filesystem for writing mount -u -o rw /backup # snapshot of the perms ls -lRafh /* > /backup/perms_snaps/${PERMS}.${SVR}.perms.snap tar -czf /backup/perms_snaps/${PERMS}.${SVR}.perms.snap.tar.gz /backup/perms_snaps/${PERMS}.${SVR}.perms.snap rm /backup/perms_snaps/${PERMS}.${SVR}.perms.snap chmod 400 /backup/perms_snaps/* # create the backup dirs for the day/week/year mkdir -p /backup/${DAY1}/ # rm the old backups rm -rf /backup/${DAY2} ${PRE} -bapoguLxSRC --exclude=3D*.core --exclude=3D*~* / --exclude=3D/dev --exclude=3D/backup /backup/${DAY1}/ ${PRE} -bapoguLxSRC --exclude=3D*.core --exclude=3D*~* /var /backup/${DAY1}= / ${PRE} -bapoguLxSRC --exclude=3D*.core --exclude=3D*~* --exclude=3D/usr/src --exclude=3D/usr/ports --exclude=3D/usr/obj /usr /backup/${DAY1}/ # Make the file system read only again mount -u -o ro /backup