Re: rsync script not excluding dirs

2006-03-20 Thread Alex Zbyslaw

Parv wrote:


in message <[EMAIL PROTECTED]>,
wrote Pat Maddox thusly...
 


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. 
   


...
 


/, /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?
   


...
 


PRE="/usr/local/bin/rsync"
${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}/
   



Your script seems to have wrapped by your mail client.

Anyway, in rsync(1) man page, see "INCLUDE/EXCLUDE PATTERN RULES"
section, point 2 ...

 o if the pattern ends with a / then it will only  match  a  direc-
   tory, not a file, link, or device.


In other words, none of your exclude patterns for directories end in
'/' , thus the backup, src, ports, etc. directories are not
excluded.
 

I'm not sure that's true.  It says a pattern ending in slash only 
matches a directory, it doesn't say that a pattern not ending in slash 
won't match a directory.


However, the patterns are anchored wrongly.  Absolute patterns are still 
relative to to tree being transferred.  So --exclude=/usr/obj when 
transferring /usr would try to match /usr/usr/obj, which is wrong.  Take 
the name of the filesystem being rsynced off those patterns and you 
should find them excluded as you want.


The rsync man page does try to explain this: it is a bit long and can 
take a few reads, but look at the FILTER RULES and ANCHORED PATTERNS... 
sections.


--Alex

PS Your flags are way over the top.  -a already includes -rlptgoD so you 
don't need them again.  Do you really want -R and I think that knocks 
the top-level directory off the files which are unpacked?  And if this 
is a backup, then why -u?  That's for use when you are changing files on 
the destination and don't want those changes overwritten, which doesn't 
sound like what you are doing.  And if it is a backup, then you might 
also want -H to preserve hard links.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: rsync script not excluding dirs

2006-03-19 Thread Parv
in message <[EMAIL PROTECTED]>,
wrote Pat Maddox thusly...
>
> 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. 
...
> /, /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?
...
> PRE="/usr/local/bin/rsync"
> ${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}/

Your script seems to have wrapped by your mail client.

Anyway, in rsync(1) man page, see "INCLUDE/EXCLUDE PATTERN RULES"
section, point 2 ...

  o if the pattern ends with a / then it will only  match  a  direc-
tory, not a file, link, or device.


In other words, none of your exclude patterns for directories end in
'/' , thus the backup, src, ports, etc. directories are not
excluded.

  - Parv

-- 

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


rsync script not excluding dirs

2006-03-19 Thread Pat Maddox
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
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"