开发者

how to rsync from one server to another with the path defined by variable say $PATH?

Hi i want to copy data fro开发者_开发百科m one server to another using rsync but my path to copy data is stored in a variable which i got from the database.


I think you need to read rsync's man page and what it tells about trailing slashes:

A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:

   rsync -av /src/foo /dest
   rsync -av /src/foo/ /dest/foo


Without knowing the actual rsync call it's a bit difficult to understand what is happening. OTOH, "to make it copy only the updated files" depends on what you mean by "updated". From the man page:

-c, --checksum

This changes the way rsync checks if the files have been changed and are in need of a transfer. Without this option, rsync uses a "quick check" that (by default) checks if each file’s size and time of last modification match between the sender and receiver. This option changes this to compare a 128-bit checksum for each file that has a matching size. Generating the checksums means that both sides will expend a lot of disk I/O reading all the data in the files in the transfer (and this is prior to any reading that will be done to transfer changed files), so this can slow things down significantly.


It's because your treating the directory as a file.

Setup

mkdir foo
touch foo/a
mkdir /tmp/foo

Problem

rsync -av foo /tmp/foo

Solution

rsync -av foo/ /tmp/foo  # Notice foo has a trailing '/'
rsync -av foo/. /tmp/foo # Another way to do the same thing
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜