rsync of file list

Matt McCutchen hashproduct at verizon.net
Sun Jan 15 15:56:31 GMT 2006


On Sun, 2006-01-15 at 09:15 +0200, Mark, Oren wrote:
> Can I do it one single rsync command, giving a file containing list of
> paths as parameter, or do I need to run rsync for each file.

It looks like this is what you need.

       --files-from=FILE
              Using this option allows you to specify the exact list of  files
              to transfer (as read from the specified FILE or "-" for standard
              input).  It also tweaks the default behavior of  rsync  to  make
              transferring just the specified files and directories easier:

              o      The  --relative  (-R)  option is implied, which preserves
                     the path information that is specified for each  item  in
                     the  file  (use  --no-relative  if  you want to turn that
                     off).

              o      The --dirs (-d) option  is  implied,  which  will  create
                     directories  specified  in  the  list  on the destination
                     rather than noisily skipping them.

              o      The --archive  (-a)  option´s  behavior  does  not  imply
                     --recursive  (-r),  so specify it explicitly, if you want
                     it.

              The file names that are read from the FILE are all  relative  to
              the  source  dir  -- any leading slashes are removed and no ".."
              references are allowed to go higher than the  source  dir.   For
              example, take this command:

                 rsync -a --files-from=/tmp/foo /usr remote:/backup

              If  /tmp/foo  contains  the  string  "bin" (or even "/bin"), the
              /usr/bin directory will be created as /backup/bin on the  remote
              host.   If  it  contains  "bin/"  (note the trailing slash), the
              immediate contents of the directory would also be sent  (without
              needing  to be explicitly mentioned in the file -- this began in
              version 2.6.4).  In both cases, if the -r  option  was  enabled,
              that  dir´s  entire hierarchy would also be transferred (keep in
              mind that -r needs to be specified explicitly with --files-from,
              since  it  is  not implied by -a).  Also note that the effect of
              the (enabled by default) --relative option is to duplicate  only
              the  path  info  that is read from the file -- it does not force
              the duplication of the source-spec path (/usr in this case).

              In addition, the --files-from file can be read from  the  remote
              host instead of the local host if you specify a "host:" in front
              of the file (the host must match one end of the transfer).  As a
              short-cut, you can specify just a prefix of ":" to mean "use the
              remote end of the transfer".  For example:

                 rsync -a --files-from=:/path/file-list src:/ /tmp/copy

              This would copy all the files specified in  the  /path/file-list
              file that was located on the remote "src" host.

Now, here's something I'm wondering: is there a way, given a list of
unrelated (source, destination) pairs, to copy each source to the
corresponding destination in a single run of rsync?
-- 
Matt McCutchen, ``hashproduct''
hashproduct at verizon.net -- http://mysite.verizon.net/hashproduct/



More information about the rsync mailing list