f+++++++++ 是什么意思? rsync 日志中的意思是什么?
我正在使用 rsync
备份我的服务器文件,我有两个问题:
在该过程中我需要停止并启动
rsync
再次。rsync
会从停止的位置开始还是会从头开始?在日志文件中我看到
“f+++++++++”
。这是什么意思?
例如:
2010/12/21 08:28:37 [4537] >f.st...... iddd/logs/website-production-access_log
2010/12/21 08:29:11 [4537] >f.st...... iddd/web/website/production/shared/log/production.log
2010/12/21 08:29:14 [4537] .d..t...... iddd/web/website/production/shared/sessions/
2010/12/21 08:29:14 [4537] >f+++++++++ iddd/web/website/production/shared/sessions/ruby_sess.017a771cc19b18cd
2010/12/21 08:29:14 [4537] >f+++++++++ iddd/web/website/production/shared/sessions/ruby_sess.01eade9d317ca79a
I'm using rsync
to make a backup of my server files, and I have two questions:
In the middle of the process I need to stop and start
rsync
again.
Willrsync
start from the point where it stopped or it will restart from the beginning?In the log files I see
"f+++++++++"
. What does it mean?
e.g.:
2010/12/21 08:28:37 [4537] >f.st...... iddd/logs/website-production-access_log
2010/12/21 08:29:11 [4537] >f.st...... iddd/web/website/production/shared/log/production.log
2010/12/21 08:29:14 [4537] .d..t...... iddd/web/website/production/shared/sessions/
2010/12/21 08:29:14 [4537] >f+++++++++ iddd/web/website/production/shared/sessions/ruby_sess.017a771cc19b18cd
2010/12/21 08:29:14 [4537] >f+++++++++ iddd/web/website/production/shared/sessions/ruby_sess.01eade9d317ca79a
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
让我们看一下 rsync 是如何工作的,并更好地理解神秘的结果行:
1 - rsync 的一个巨大优势是,在中断后,下一次它会顺利继续。
如果在此期间未更改文件,则下一次 rsync 调用将不会再次传输已传输的文件。但它会从头开始再次检查所有文件以找出答案,因为它不知道它已被中断。
2 - 每个字符都是一个可以翻译的代码,如果您阅读
man rsync
中的-i, --itemize-changes
部分,从问题中解码示例日志文件:
>f.st......
.d..t......
>f+++++++++
rsync 手册页:
Let's take a look at how rsync works and better understand the cryptic result lines:
1 - A huge advantage of rsync is that after an interruption the next time it continues smoothly.
The next rsync invocation will not transfer the files again, that it had already transferred, if they were not changed in the meantime. But it will start checking all the files again from the beginning to find out, as it is not aware that it had been interrupted.
2 - Each character is a code that can be translated if you read the section for
-i, --itemize-changes
inman rsync
Decoding your example log file from the question:
>f.st......
.d..t......
>f+++++++++
The relevant part of the rsync man page:
不久前,我需要了解我正在编写的脚本的 rsync 输出。在编写该脚本的过程中,我在谷歌上进行了搜索,找到了 @mit 上面所写的内容。我使用这些信息以及其他来源的文档,创建了我自己的关于位标志的入门读物,以及如何让 rsync 为所有操作输出位标志(默认情况下不这样做) 。
我在这里发布这些信息是希望它能帮助其他人(像我一样)通过搜索偶然发现此页面并需要更好地解释
rsync
。通过结合
--itemize-changes
标志和-vvv
标志,rsync
为我们提供了详细的输出与目标目录相比,在源目录中识别出的所有文件系统更改的数量。然后可以对 rsync 生成的位标志进行解码以确定发生了什么变化。要解码每个位的含义,请使用下表。rsync 输出中每个位位置和值的说明:
Some time back, I needed to understand the
rsync
output for a script that I was writing. During the process of writing that script I googled around and came to what @mit had written above. I used that information, as well as documentation from other sources, to create my own primer on the bit flags and how to getrsync
to output bit flags for all actions (it does not do this by default).I am posting that information here in hopes that it helps others who (like me) stumble up on this page via search and need a better explanation of
rsync
.With the combination of the
--itemize-changes
flag and the-vvv
flag,rsync
gives us detailed output of all file system changes that were identified in the source directory when compared to the target directory. The bit flags produced byrsync
can then be decoded to determine what changed. To decode each bit's meaning, use the following table.Explanation of each bit position and value in
rsync
's output:|
|
╰- x: The extended attribute information changed
|||||||||╰-- a: The ACL information changed
||||||||╰--- u: The u slot is reserved for future use
|||||||╰---- g: Group is different
||||||╰----- o: Owner is different
|||||╰------ p: Permission are different
||||╰------- t: Modification time is different
|||╰-------- s: Size is different
||╰--------- c: Different checksum (for regular files), or
|| changed value (for symlinks, devices, and special files)
|╰---------- the file type:
| f: for a file,
| d: for a directory,
| L: for a symlink,
| D: for a device,
| S: for a special file (e.g. named sockets and fifos)
╰----------- the type of update being done::
<: file is being transferred to the remote host (sent)
>: file is being transferred to the local host (received)
c: local change/creation for the item, such as:
- the creation of a directory
- the changing of a symlink,
- etc.
h: the item is a hard link to another item (requires
--hard-links).
.: the item is not being updated (though it might have
attributes that are being modified)
*: means that the rest of the itemized-output area contains
a message (e.g. "deleting")
rsync 针对各种场景的一些示例输出:
捕获
rsync
的输出(重点关注位标志):在我的实验中,< code>--itemize-changes 标志和
-vvv
标志需要让rsync
输出 所有文件系统更改。如果没有三重详细 (-vvv
) 标志,我就看不到列出的目录、链接和设备更改。值得尝试您的 rsync 版本,以确保它观察并记录您所期望的所有内容。这种技术的一个方便的用法是将
--dry-run
标志添加到命令中,并将由 rsync 确定的更改列表收集到变量中(不进行任何更改),这样您就可以执行以下操作:自己对单子进行一些处理。类似下面的内容将捕获变量中的输出:在上面的示例中,rsync 的(stdout)输出被重定向到 grep (通过 stdin),因此我们可以隔离仅包含位标志的行。
处理捕获的输出:
然后可以记录变量的内容以供以后使用或立即迭代以获取感兴趣的项目。我在研究更多关于 rsync 的过程中编写的脚本中使用了这种策略。您可以查看脚本(https://github.com/jmmitchell/movestough)以获取帖子示例-处理捕获的输出以隔离新文件、重复文件(相同名称、相同内容)、文件冲突(相同名称、不同内容)以及子目录结构的更改。
╰- x: The extended attribute information changed
|||||||||╰-- a: The ACL information changed
||||||||╰--- u: The u slot is reserved for future use
|||||||╰---- g: Group is different
||||||╰----- o: Owner is different
|||||╰------ p: Permission are different
||||╰------- t: Modification time is different
|||╰-------- s: Size is different
||╰--------- c: Different checksum (for regular files), or
|| changed value (for symlinks, devices, and special files)
|╰---------- the file type:
| f: for a file,
| d: for a directory,
| L: for a symlink,
| D: for a device,
| S: for a special file (e.g. named sockets and fifos)
╰----------- the type of update being done::
<: file is being transferred to the remote host (sent)
>: file is being transferred to the local host (received)
c: local change/creation for the item, such as:
- the creation of a directory
- the changing of a symlink,
- etc.
h: the item is a hard link to another item (requires
--hard-links).
.: the item is not being updated (though it might have
attributes that are being modified)
*: means that the rest of the itemized-output area contains
a message (e.g. "deleting")
Some example output from rsync for various scenarios:
Capturing
rsync
's output (focused on the bit flags):In my experimentation, both the
--itemize-changes
flag and the-vvv
flag are needed to getrsync
to output an entry for all file system changes. Without the triple verbose (-vvv
) flag, I was not seeing directory, link and device changes listed. It is worth experimenting with your version of rsync to make sure that it is observing and noting all that you expected.One handy use of this technique is to add the
--dry-run
flag to the command and collect the change list, as determined by rsync, into a variable (without making any changes) so you can do some processing on the list yourself. Something like the following would capture the output in a variable:In the example above, the (stdout) output from
rsync
is redirected togrep
(via stdin) so we can isolate only the lines that contain bit flags.Processing the captured output:
The contents of the variable can then be logged for later use or immediately iterated over for items of interest. I use this exact tactic in the script I wrote during researching more about
rsync
. You can look at the script (https://github.com/jmmitchell/movestough) for examples of post-processing the captured output to isolate new files, duplicate files (same name, same contents), file collisions (same name, different contents), as well as the changes in subdirectory structures.1.) 它将“重新启动同步”,但不会传输相同大小和时间戳等的文件。它首先建立要传输的文件列表,在此阶段它将看到它已经传输了一些文件并会跳过它们。您应该告诉 rsync 保留时间戳等(例如使用 rsync -a ...)
当 rsync 传输文件时,它会调用类似
.filename.XYZABC
的名称。 > 而不是文件名
。然后,当它完成该文件的传输时,它将重命名它。因此,如果您在 rsync 传输大文件时终止它,则必须使用 --partial 选项来继续传输,而不是从头开始。2.) 我不知道那是什么。你能贴一些例子吗?
编辑:根据 http://ubuntuforums.org/showthread.php?t=1342171这些代码在 rsync 手册页的
-i, --itemize-changes
选项部分中定义。如果我的答案基于 Joao 的,则修复部分
1.) It will "restart the sync", but it will not transfer files that are the same size and timestamp etc. It first builds up a list of files to transfer and during this stage it will see that it has already transferred some files and will skip them. You should tell rsync to preserve the timestamps etc. (e.g. using
rsync -a ...
)While rsync is transferring a file, it will call it something like
.filename.XYZABC
instead offilename
. Then when it has finished transferring that file it will rename it. So, if you kill rsync while it is transferring a large file, you will have to use the --partial option to continue the transfer instead of starting from scratch.2.) I don't know what that is. Can you paste some examples?
EDIT: As per http://ubuntuforums.org/showthread.php?t=1342171 those codes are defined in the rsync man page in section for the the
-i, --itemize-changes
option.Fixed part if my answer based on Joao's