rsync --files-from with symlink in path
Jeremy Grant
jgrant at vml.com
Wed Mar 24 00:33:48 GMT 2004
Here is what I have been doing with rsync(This is condinced version of
the main script that runs):
#!/usr/local/bin/bash
SSH=/usr/local/bin/ssh
RSYNC=/usr/local/bin/rsync
SED=/usr/bin/sed
USER=vmladmin
ROLLLISTDIR=/home/vmladmin/rolllists/
ROLLFILE=${ROLLLISTDIR}rollfile.${CELERITYID}
EXCLUDEFILE=${ROLLLISTDIR}rollfile.exclude
RSYNC_OPT="-zrc --delete"
EXCLUDE="--exclude-from=${EXCLUDEFILE}"
BACKUP="--backup-dir=/opt/staging/rollbackup/${CELERITYID}-`date
+%Y%m%d%H%M`"
rsyncfiles ()
{
SERVER=${1}
SRCDIR=${2}
DESTDIR=${3}
for FILES in `cat ${ROLLFILE} | sed 's~ $~~g' | tr " " "@"`
do
FNAME=`echo ${FILES} | ${SED} 's~@~\ ~g'`
${RSYNC} -e "${SSH}" -nv ${RSYNC_OPT} ${EXCLUDE}
${BAKCUP} "${SRCDIR}${FNAME}" ${USER}@${SERVER}:"${DESTDIR}${FNAME}"
done
}
What my script does, takes a list of filename found in ${ROLLFILE} and
runs a for loop that uses rsync to move the list of files from one
server to another. This work correctly even syncing files that exist in
a dir that is symlinked to another dir on the file system. After
upgrading to 2.6.0 when I moved to newer servers I decided to change my
script some. One of the things I am to make work is the --files-from
option that is now avalible. Here is somewhat of what my new script
does:
#!/usr/local/bin/bash
###OPTIONS####
rsyncfiles ()
{
RSYNC_OPT=${1}
FROMFILE=${2}
SOURCE=${3} # user at host: or :
DESTINATION=${4} # user at host: or :
if [ -r "${FROMFILE}" ]
then
echo ${RSYNCCMD} -e "${SSH}" ${RSYNC_OPT} ${EXCLUDE} ${INCLUDE}
--files-from=${FROMFILE} ${SOURCE} ${DESTINATION}
${RSYNCCMD} -e "${SSH}" ${RSYNC_OPT} ${EXCLUDE}
${INCLUDE} --files-from=${FROMFILE} ${SOURCE} ${DESTINATION}
fi
}
Which I pass a command like:
rsyncfiles "${RSYNC_OPT}" "${WEBROLLFILE}" "/"
"${USER}@prodweb1:/"
This now give me an error like this when I sync the same filelist that
works with the first setup:
delete_file: unlink "//opt/bea/vml" failed: Permission denied
symlink "//opt/bea/vml" ->
"/opt/bea/user_projects/domains/cp-sb1/applications" failed: File exists
rsync error: some files could not be transferred (code 23) at
main.c(632)
The new script works great as long as there is a not a symlinked dir in
the path. So far I have nto been able to find anything on the list or
in the main page to help me with this. Does anyone have any ideas how I
get this to work with the --files-from option?
Jeremy Grant
Unix System Admin
VML
More information about the rsync
mailing list