通过管道将 rsync 输出传输到文件

发布于 2024-12-11 10:56:36 字数 369 浏览 0 评论 0原文

是否可以将输出(原始数据,无日志记录)通过管道传输到 rsync 文件,并可能将其保存到 bsdiff 中?我发现 rsnapshot 由于缺乏配置和愚蠢的语法(缩进,wtf?)而非常令人恼火,而 rdiff 则有点不稳定。

我有一个可行的解决方案,我将所有数据同步,制作一个 tar.gz 存档,并使用 bsdiff 在两个 tar.gz 存档之间生成补丁。但这对于巨大的负载来说是相当 CPU 密集型的,并且非常磁盘密集型的,因为您每次都必须制作整个存档。

总结一下: - 进行初始rsync - 将其与以前的文件进行 bsdiff - 以一种易于恢复的方式存档差异

当我写这篇文章时,我刚刚有了一个关于 lvm-snapshot 的想法,有人知道我应该如何继续吗?

Is it possible to pipe the output (raw data, no logging) to a file of rsync, and maybe save this to a bsdiff? I find rsnapshot to be highly irritating with the lack of configuration and stupid syntax (indenting, wtf?) and rdiff to be a little unstable.

I have a working solution where i rsync all the data over, make a tar.gz-archive of it and bsdiff to generate a patch between two tar.gz-archives. But this is pretty CPU intensive on huge loads and very disk intensive, as you have to make the entire archive every time.

To sum it up:
- Make the initial rsync
- bsdiff it against the previous files
- Archive the diff in a way to make it easy to recover

When i wrote this i just got an idea with lvm-snapshot, any takers on how I should go forth with that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

我的影子我的梦 2024-12-18 10:56:36

rsync(1) 在联系远程系统时可以轻松使用不同的 shell; -e ssh 是默认设置,但您可以编写一个包装程序来启动 ssh 并保存转发到 ssh 的所有内容的副本代码>.

我想到的一些伪代码:

in[2] = pipe
out[2] = pipe
err[2] = pipe
fork
if child, fork
grandparent /* ssh */
    close 0, 1, 2
    dup2 in[0], 0
    dup2 out[1], 1
    dup2 err[1], 2
    close in, out, err
    exec(ssh, hostname, rsync) -- copy from rsync itself
parent /* stdin -> pipe */
    close in[0], out, err, 1, 2
    open (log, "/path/to/log", "w")
    loop forever:
        read(0, buf)
        write(in[1], buf)
        write(log, buf)
child /* pipe -> stdout, stderr */
    close in, out[1], err[1], 0
    loop forever:
        read(out[0], bufout)
        write(1, bufout)
        read(err[0], buferr)
        write(2, buferr)

请仔细检查 pipe(2)dup2(2)close(2)< /code> 在实现此之前调用;我相信我正确连接了描述符并关闭了每个进程中未使用的描述符,但这有点微妙。

我不知道您将生成的文件应用到远程端点的 tarball 有多容易,但我希望这不是您所困扰的部分。

rsync(1) can use a different shell easily when contacting remote systems; -e ssh is the default, but you could write a wrapper program that starts ssh and saves a copy of all the content that you forward along to ssh.

Some pseudo-code for what I'm thinking of:

in[2] = pipe
out[2] = pipe
err[2] = pipe
fork
if child, fork
grandparent /* ssh */
    close 0, 1, 2
    dup2 in[0], 0
    dup2 out[1], 1
    dup2 err[1], 2
    close in, out, err
    exec(ssh, hostname, rsync) -- copy from rsync itself
parent /* stdin -> pipe */
    close in[0], out, err, 1, 2
    open (log, "/path/to/log", "w")
    loop forever:
        read(0, buf)
        write(in[1], buf)
        write(log, buf)
child /* pipe -> stdout, stderr */
    close in, out[1], err[1], 0
    loop forever:
        read(out[0], bufout)
        write(1, bufout)
        read(err[0], buferr)
        write(2, buferr)

Please double-check the pipe(2), dup2(2), and close(2) calls before implementing this; I believe I hooked up the descriptors properly and closed the unused descriptors in each process, but this is a little subtle.

I don't know how easy it will be for you to apply the resulting file to your remote endpoint's tarball, but I hope that's not the part you're stuck on.

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