对于上次未传完的文件,rsync默认会删除已经下载的,然后重新传输
但它同时也提供了一个–partial参数来实现续传功能,还是挺方便的
而–partial-dir可以用来设置续传文件的保存路径,man中的说明如下:
–partial
By default, rsync will delete any partially transferred file if the transfer is interrupted. In some circumstances it is more desirable to keep partially transferred files. Using the –partial option tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.
–partial-dir=DIR
A better way to keep partial files than the –partial option is to specify a DIR that will be used to hold the partial data (instead of writing it out to the destination file). On the next transfer, rsync will use a file found in this dir as data to speed up the resumption of the transfer and then delete it after it has served its purpose.
Note that if –whole-file is specified (or implied), any partial-dir file that is found for a file that is being updated will simply be removed (since rsync is sending files without using the incremental rsync algorithm).
Rsync will create the DIR if it is missing (just the last dir — not the whole path). This makes it easy to use a relative path (such as “–partial-dir=.rsync-partial”) to have rsync create the partial-directory in the destination file’s directory when needed, and then remove it again when the partial file is deleted.
If the partial-dir value is not an absolute path, rsync will add an exclude rule at the end of all your existing excludes. This will prevent the sending of any partial-dir files that may exist on the sending side, and will also prevent the untimely deletion of partial-dir items on the receiving side. An example: the above –partial-dir option would add the equivalent of “–exclude=.rsync-partial/” at the end of any other filter rules.
If you are supplying your own exclude rules, you may need to add your own exclude/hide/protect rule for the partial-dir because (1) the auto-added rule maybe ineffective at the end of your other rules, or (2) you may wish to override rsync’s exclude choice. For instance, if you want to make rsync clean-up any left-over partial-dirs that may be lying around, you should specify –delete-after and add a “risk” filter rule, e.g. -f ‘R .rsync-partial/’. (Avoid using –delete-before or –delete-during unless you don’t need rsync to use any of the left-over partial-dir data during the current run.)
IMPORTANT: the –partial-dir should not be writable by other users or it is a security risk. E.g. AVOID “/tmp”.
You can also set the partial-dir value the RSYNC_PARTIAL_DIR environment variable. Setting this in the environment does not force –partial to be enabled, but rather it affects where partial files go when –partial is specified. For instance, instead of using –partial-dir=.rsync-tmp along with –progress, you could set RSYNC_PARTIAL_DIR=.rsync-tmp in your environment and then just use the -P option to turn on the use of the .rsync-tmp dir for partial transfers.
The only times that the –partial option does not look for this environment value are (1) when –inplace was specified (since –inplace conflicts with –partial-dir), and (2) when –delay-updates was specified (see below).
For the purposes of the daemon-config’s “refuse options” setting, –partial-dir does not imply –partial. This is so that a refusal of the –partial option can be used to disallow the overwriting of destination files with a partial transfer, while still allowing the safer idiom provided by –partial-dir.