Hi people. My first post so be lenient :) I have read stuff on rsync, looked through the options and read the man page but cannot seem to find an answer to my problem. Ok. I have a script which connects to a remote machine via ssh and pulls back a list of source directories/files from a config file on the remote server. I then loop these lines and do an rsync for each item to pull the files back to my local machine. The rsync syntax im using is this (there is much more in the script im just pulling out important bits) :- RSYNC_BIN=$(/usr/bin/which rsync) # May want to drop the v verbose RSYNC_OPTS=" -Pvprtlz --delete --delete-excluded --copy-unsafe-links --numeric-ids" RSYNC="${RSYNC_BIN} ${RSYNC_OPTS}" # Ok here is the Rsync loop for RLIST in ${remote_get_list} do # Going to put a safety test here in case / is file list if [ "${RLIST}" = "/" ];then echo "\n[Remote_Get for ${remote_get_host}]\n\tWARNING:We dont want / as a source. Too intense so skipping." >> ${remote_errorlog} continue fi # Rsync output will be logging to error file so # need list there too for clarity echo "\n\tStaring get of [${RLIST}]" >> ${remote_mainlog} echo "\n\tStaring get of [${RLIST}]\n" >> ${remote_errorlog} ${RSYNC} -e ssh 2>/dev/null user@${remote_get_host}:${RLIST} ${remote_get_localdir} >> ${remote_errorlog} 2>> ${remote_errorlog} # Check each Rsync run was successful or had errors if [ $? = 0 ];then echo "\tGet of [${RLIST}] status [Successful]">> ${remote_mainlog}else echo "\tGet of [${RLIST}] status [Suspect]\n\tSee [${remote_errorlog}]" >> ${remote_mainlog} fi done Now ${remote_get_list} is a variable containing a list of files or dirs from a config file which looks like this :- ( obviously comments, blank lines are ignore ) # This is a comment line # so is this ## multiple hashes #/location1 #/ #/loction2/somwhere #/dir/dir2/file #Plus comments here /tmp/davefile2 /export/home/user The question i have is this :- when i run the script using the above config file it only creates locally :- ${remote_get_localdir}/davefile2 ${remote_get_localdir}/user I see this as a problem as what if i have the following in the config file :- /etc/inet/hosts /export/home/user/hosts This will create ${remote_get_localdir}/hosts from source /etc/inet/hosts and then overwrite it with /export/home/user/hosts. Is this correct? What i want is for rsync to create this :- ${remote_get_localdir}/etc/inet/hosts ${remote_get_localdir}/export/home/users/hosts Anyone any ideas?
On Fri, Feb 16, 2007 at 01:42:47PM +0000, Dave Markham wrote:> Is this correct? What i want is for rsync to create this :- > > ${remote_get_localdir}/etc/inet/hosts > ${remote_get_localdir}/export/home/users/hostsSee the --relative option and the --files-from=FILE option (which implies --relative). ..wayne..