rsync script not excluding dirs

Pat Maddox pergesu at gmail.com
Sun Mar 19 21:55:20 UTC 2006


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. 
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=/
PATH=/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=`date +%Y%m%d`

SVR="cantona"

# forward dating
DAY1=`date +%Y/${SVR}/%m/%d`

# reverse dating for removal of old backup
DAY2=`date -j -v-1w +%Y/${SVR}/%m/%d`

PRE="/usr/local/bin/rsync"

ARG=`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=*.core --exclude=*~* / --exclude=/dev
--exclude=/backup /backup/${DAY1}/
${PRE} -bapoguLxSRC --exclude=*.core --exclude=*~* /var /backup/${DAY1}/
${PRE} -bapoguLxSRC --exclude=*.core --exclude=*~* --exclude=/usr/src
--exclude=/usr/ports --exclude=/usr/obj /usr /backup/${DAY1}/

# Make the file system read only again
mount -u -o ro /backup


More information about the freebsd-questions mailing list