f+++++++++ 是什么意思? rsync 日志中的意思是什么?

发布于 2024-10-08 16:56:00 字数 741 浏览 0 评论 0原文

我正在使用 rsync 备份我的服务器文件,我有两个问题:

  1. 在该过程中我需要停止并启动 rsync再次。
    rsync 会从停止的位置开始还是会从头开始?

  2. 在日志文件中我看到“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:

  1. In the middle of the process I need to stop and start rsync again.
    Will rsync start from the point where it stopped or it will restart from the beginning?

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

败给现实 2024-10-15 16:56:00

让我们看一下 rsync 是如何工作的,并更好地理解神秘的结果行:

1 - rsync 的一个巨大优势是,在中断后,下一次它会顺利继续。

如果在此期间未更改文件,则下一次 rsync 调用将不会再次传输已传输的文件。但它会从头开始再次检查所有文件以找出答案,因为它不知道它已被中断。

2 - 每个字符都是一个可以翻译的代码,如果您阅读 man rsync 中的 -i, --itemize-changes 部分,

从问题中解码示例日志文件:

>f.st......

> - the item is received
f - it is a regular file
s - the file size is different
t - the time stamp is different

.d..t......

. - the item is not being updated (though it might have attributes 
    that are being modified)
d - it is a directory
t - the time stamp is different

>f+++++++++

> - the item is received
f - a regular file
+++++++++ - this is a newly created item

rsync 手册页

-i, --itemize-changes

请求一份简单的逐项列表,列出正在进行的更改
每个文件,包括属性更改。这与
指定 --out-format='%i %n%L'。如果重复该选项,则不变
文件也会被输出,但前提是接收 rsync 至少是
版本 2.6.7(您可以将 -vv 与旧版本的 rsync 一起使用,但是
还打开其他详细消息的输出)。

“%i”转义符有一个 11 个字母长的神秘输出。这
一般格式类似于字符串 YXcstpoguax,其中 Y 替换为
正在完成的更新类型,X 被文件类型替换,并且
其他字母表示如果满足则可以输出的属性
正在修改。

替换Y的更新类型如下:

  • < 表示文件正在传输到远程主机(发送)。
  • > 表示文件正在传输到本地主机(已接收)。
  • c 表示该项目正在发生本地更改/创建(例如创建目录或更改符号链接,
    等)。
  • h 表示该项目是到另一个项目的硬链接(需要 --hard-links)。
  • A . 表示该项目未更新(尽管它可能具有正在修改的属性)。
  • * 表示逐项输出区域的其余部分包含一条消息(例如“删除”)。

替换 X 的文件类型是:f 表示文件,d 表示文件
目录,L 表示符号链接,D 表示设备,S 表示设备
特殊文件(例如命名套接字和fifos)。

上面字符串中的其他字母是实际的字母
如果项目的关联属性正在更新或
一个“。”没有任何改变。三个例外是: (1) 新创建的
item 用“+”替换每个字母,(2) 相同的 item 替换
带空格的点,以及 (3) 未知属性替换每个点
带有“?”的字母(与较旧的 rsync 通信时可能会发生这种情况)。

与每个字母关联的属性如下:

  • c 表示常规文件具有不同的校验和(需要 --checksum),或者符号链接、设备或特殊文件具有不同的校验和。
    改变了值。请注意,如果您在之前将文件发送到 rsync
    3.0.1 中,此更改标志仅适用于校验和不同的常规文件。
  • s 表示常规文件的大小不同,并且会通过文件传输进行更新。
  • t 表示修改时间不同,正在更新为发送者的值(需要 --times)。 T 的替代值
    表示修改时间将设置为传输时间,
    当文件/符号链接/设备在没有 --times 的情况下更新时会发生这种情况
    当符号链接更改并且接收者无法设置其时间时。
    (注意:当使用 rsync 3.0.0 客户端时,您可能会看到 s 标志
    与 t 结合,而不是此时间设置的正确 T 标志
    失败。)
  • p 表示权限不同,并且正在更新为发件人的值(需要 --perms)。
  • o 表示所有者不同,并且正在更新为发送者的值(需要 --owner 和超级用户权限)。
  • g 表示组不同,并且正在更新为发件人的值(需要 --group 和设置组的权限)。
  • u 插槽保留供将来使用。
  • a 表示 ACL 信息已更改。
  • x表示扩展属性信息发生变化。

另一种输出是可能的:删除文件时,“%i”将
为每个要删除的项目输出字符串“*deleting”
(假设您正在与一个最近的 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 in man rsync

Decoding your example log file from the question:

>f.st......

> - the item is received
f - it is a regular file
s - the file size is different
t - the time stamp is different

.d..t......

. - the item is not being updated (though it might have attributes 
    that are being modified)
d - it is a directory
t - the time stamp is different

>f+++++++++

> - the item is received
f - a regular file
+++++++++ - this is a newly created item

The relevant part of the rsync man page:

-i, --itemize-changes

Requests a simple itemized list of the changes that are being made to
each file, including attribute changes. This is exactly the same as
specifying --out-format='%i %n%L'. If you repeat the option, unchanged
files will also be output, but only if the receiving rsync is at least
version 2.6.7 (you can use -vv with older versions of rsync, but that
also turns on the output of other verbose messages).

The "%i" escape has a cryptic output that is 11 letters long. The
general format is like the string YXcstpoguax, where Y is replaced by
the type of update being done, X is replaced by the file-type, and the
other letters represent attributes that may be output if they are
being modified.

The update types that replace the Y are as follows:

  • A < means that a file is being transferred to the remote host (sent).
  • A > means that a file is being transferred to the local host (received).
  • A c means that a local change/creation is occurring for the item (such as the creation of a directory or the changing of a symlink,
    etc.).
  • A h means that the item is a hard link to another item (requires --hard-links).
  • A . means that the item is not being updated (though it might have attributes that are being modified).
  • A * means that the rest of the itemized-output area contains a message (e.g. "deleting").

The file-types that replace the X are: f for a file, a d for a
directory, an L for a symlink, a D for a device, and a S for a
special file (e.g. named sockets and fifos).

The other letters in the string above are the actual letters that will
be output if the associated attribute for the item is being updated or
a "." for no change. Three exceptions to this are: (1) a newly created
item replaces each letter with a "+", (2) an identical item replaces
the dots with spaces, and (3) an unknown attribute replaces each
letter with a "?" (this can happen when talking to an older rsync).

The attribute that is associated with each letter is as follows:

  • A c means either that a regular file has a different checksum (requires --checksum) or that a symlink, device, or special file has a
    changed value. Note that if you are sending files to an rsync prior to
    3.0.1, this change flag will be present only for checksum-differing regular files.
  • A s means the size of a regular file is different and will be updated by the file transfer.
  • A t means the modification time is different and is being updated to the sender’s value (requires --times). An alternate value of T
    means that the modification time will be set to the transfer time,
    which happens when a file/symlink/device is updated without --times
    and when a symlink is changed and the receiver can’t set its time.
    (Note: when using an rsync 3.0.0 client, you might see the s flag
    combined with t instead of the proper T flag for this time-setting
    failure.)
  • A p means the permissions are different and are being updated to the sender’s value (requires --perms).
  • An o means the owner is different and is being updated to the sender’s value (requires --owner and super-user privileges).
  • A g means the group is different and is being updated to the sender’s value (requires --group and the authority to set the group).
  • The u slot is reserved for future use.
  • The a means that the ACL information changed.
  • The x means that the extended attribute information changed.

One other output is possible: when deleting files, the "%i" will
output the string "*deleting" for each item that is being removed
(assuming that you are talking to a recent enough rsync that it logs
deletions instead of outputting them as a verbose message).

起风了 2024-10-15 16:56:00

不久前,我需要了解我正在编写的脚本的 rsync 输出。在编写该脚本的过程中,我在谷歌上进行了搜索,找到了 @mit 上面所写的内容。我使用这些信息以及其他来源的文档,创建了我自己的关于位标志的入门读物,以及如何让 rsync 为所有操作输出位标志(默认情况下不这样做) 。

我在这里发布这些信息是希望它能帮助其他人(像我一样)通过搜索偶然发现此页面并需要更好地解释 rsync

通过结合 --itemize-changes 标志 -vvv 标志,rsync 为我们提供了详细的输出与目标目录相比,在源目录中识别出的所有文件系统更改的数量。然后可以对 rsync 生成的位标志进行解码以确定发生了什么变化。要解码每个位的含义,请使用下表。

rsync 输出中每个位位置和值的说明:

YXcstpoguax  path/to/file

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 get rsync 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 by rsync 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:

YXcstpoguax  path/to/file

浅黛梨妆こ 2024-10-15 16:56:00

╰- 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 针对各种场景的一些示例输出:

>f+++++++++ some/dir/new-file.txt
.f....og..x some/dir/existing-file-with-changed-owner-and-group.txt
.f........x some/dir/existing-file-with-changed-unnamed-attribute.txt
>f...p....x some/dir/existing-file-with-changed-permissions.txt
>f..t..g..x some/dir/existing-file-with-changed-time-and-group.txt
>f.s......x some/dir/existing-file-with-changed-size.txt
>f.st.....x some/dir/existing-file-with-changed-size-and-time-stamp.txt 
cd+++++++++ some/dir/new-directory/
.d....og... some/dir/existing-directory-with-changed-owner-and-group/
.d..t...... some/dir/existing-directory-with-different-time-stamp/

捕获 rsync 的输出(重点关注位标志):

在我的实验中,< code>--itemize-changes 标志 -vvv 标志需要让 rsync 输出 所有文件系统更改。如果没有三重详细 (-vvv) 标志,我就看不到列出的目录、链接和设备更改。值得尝试您的 rsync 版本,以确保它观察并记录您所期望的所有内容。

这种技术的一个方便的用法是将 --dry-run 标志添加到命令中,并将由 rsync 确定的更改列表收集到变量中(不进行任何更改),这样您就可以执行以下操作:自己对单子进行一些处理。类似下面的内容将捕获变量中的输出:

file_system_changes=$(rsync --archive --acls --xattrs \
    --checksum --dry-run \
    --itemize-changes -vvv \
    "/some/source-path/" \
    "/some/destination-path/" \
| grep -E '^(\.|>|<|c|h|\*).......... .')

在上面的示例中,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:

>f+++++++++ some/dir/new-file.txt
.f....og..x some/dir/existing-file-with-changed-owner-and-group.txt
.f........x some/dir/existing-file-with-changed-unnamed-attribute.txt
>f...p....x some/dir/existing-file-with-changed-permissions.txt
>f..t..g..x some/dir/existing-file-with-changed-time-and-group.txt
>f.s......x some/dir/existing-file-with-changed-size.txt
>f.st.....x some/dir/existing-file-with-changed-size-and-time-stamp.txt 
cd+++++++++ some/dir/new-directory/
.d....og... some/dir/existing-directory-with-changed-owner-and-group/
.d..t...... some/dir/existing-directory-with-different-time-stamp/

Capturing rsync's output (focused on the bit flags):

In my experimentation, both the --itemize-changes flag and the -vvv flag are needed to get rsync 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:

file_system_changes=$(rsync --archive --acls --xattrs \
    --checksum --dry-run \
    --itemize-changes -vvv \
    "/some/source-path/" \
    "/some/destination-path/" \
| grep -E '^(\.|>|<|c|h|\*).......... .')

In the example above, the (stdout) output from rsync is redirected to grep (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.

戏舞 2024-10-15 16:56:00

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 of filename. 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文