Q: --one-file-system and nested file systems

Brian McEntire brianm at fsg1.nws.noaa.gov
Thu Apr 8 20:06:28 GMT 2004

Answered my own question... here's what I came up with in case anyone else
wants the answer:

FILESYSTEMS=`ssh -q root@$srcHost df -l|awk '/\// {print $NF}'|tr '\n' ''`

rsync -av -e 'ssh -q' --one-file-system --numeric-ids --relative \
    --delete root@$SRCHOST:"${FILESYSTEMS}" /backups/$SRCHOST

I used tr to translate the carriage return from the df output into a 
space. Then I used double quotes around the $FILESYSTEMS variable on the 
rsync line so that the variable could be interpreted but the value still 

If there are any better ways to do this, I'm still all ears.

On Thu, 8 Apr 2004, Brian McEntire wrote:

> Thanks Wayne! 
> > reading of the files on the source machine.  However, you can include
> > all the source filesystems as args in a single copy command and it will
> > enforce the single-filesystem (inode-based) restriction separately for
> > each arg you specify:
> > 
> >   rsync -avxR -e ssh --numeric-ids --delete \
> >     --exclude-from=/backups/control/all.exclude \
> >     root at B:'/ /usr /usr/local /usr/local/apache' /backups/B
> That works great from the command line. One follow-up question for anyone 
> with good shell scripting experience:
> I'm trying to automate this with a Bash script to grab file systems from a
> couple of remote hosts.  Here's how I get a list of the file systems local
> to the remote hosts within the script:
> FILESYSTEMS=`ssh $remHost df -l|awk '/\// {print $NF}'`
> Variable FILESYSTEMS then contains, for example:
> /
> /boot
> /var
> But when try to make the rsync call from my script:
>   rsync ... root at B:\'$FILESYSTEMS\' /backups/B
> I can't get the quoting right. I don't know if its me (probably :-) or the 
> shell or rsync. I've tried variations with '' or " but no luck yet.
> The script contains:
> rsync -av -e 'ssh -q' --one-file-system --numeric-ids --relative \
>     --delete --exclude-from=$CONTROL/all.exclude $CONDEXCLUDE \
>     root@$SRCHOST:\'${FILESYSTEMS}\' . 
> But here's what tries to get executed (set -x in the script shows each
> command to be executed):
> rsync -av -e 'ssh -q' --one-file-system --numeric-ids --relative --delete
> --exclude-from=/backups/control/all.exclude 'root at B:'\''/' /boot /dev/shm
> '/sandbox'\''' .
> Does anyone know a good way to quote or set the FILESYSTEMS variable so I 
> can effectively run, from within a script:
>   rsync ... root at B:$FILESYSTEMS that will equate to root at B:'/ /boot /var' 
> Thanks a bunch!! 
> Not that it matters, I'm amazed by the patches and responses on this list!
> Its awesome; reminds me of the old days of the Internet.  :-)

More information about the rsync mailing list