据我所知,rsync 在完成之前不会在目标目录中创建文件。
这一定意味着它在某个地方的临时目录中创建文件,并在完成后将文件复制到目标目录中。
首先,这是正确的吗?
如果为 true,rsync 是否可以设置不使用临时目录,而是在目标目录中创建文件并继续写入直到完成?
小智 62
根据手册页,您可以使用参数 -T 指定存储临时文件的目录,如
-T, --temp-dir=DIR 在目录 DIR 中创建临时文件
您问题的第二部分的答案也可以在那里找到:
- 到位
当文件的数据需要更新时,此选项会更改 rsync 传输文件的方式:与创建文件的新副本并在完成后将其移动到位的默认方法不同,rsync 将更新的数据直接写入目标文件。
ter*_*don 15
默认情况下,它会在目标目录中创建一个临时文件,并命名为.<FILE_NAME>.<RANDOM_STRING>
. 因此,如果您正在复制foo.txt
,它将创建一个名为.foo.txt.GV4H3
(GV4H3
是每次运行时都会不同的随机字符串)的 tmp 文件。您可以使用以下rsync
选项控制此行为:
--partial
By default, rsync will delete any partially transferred
file if the transfer is interrupted. In some circum?
stances it is more desirable to keep partially trans?
ferred 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 des?
tination file). On the next transfer, rsync will use a
file found in this dir as data to speed up the resump?
tion of the transfer and then delete it after it has
served its purpose.
Run Code Online (Sandbox Code Playgroud)
请阅读rsync
手册页的相关部分(以下只是关于如何使用的大部分内容的一小部分--partial-dir
)。
rsync 在目标目录中创建临时文件。该文件的名称与源文件相同,但带有扩展名。它可能是这样的:
source: foo.bar
target temp: foo.bar.hzmkjt7 (hzmkjt7 is just an example)
Run Code Online (Sandbox Code Playgroud)
在验证文件是源的精确副本后,将删除扩展名。在重命名过程中设置所有权、权限和修改时间。因此,由于权限的原因,您可能看不到该文件。确保您有足够的权限查看所有文件以及不属于您的文件,以便查看临时文件。
归档时间: |
|
查看次数: |
51459 次 |
最近记录: |