0

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?

4

1 回答 1

0

rsync(1)联系远程系统时可以轻松使用不同的外壳;-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)调用;我相信我正确连接了描述符并关闭了每个进程中未使用的描述符,但这有点微妙。

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

于 2011-10-22T06:31:58.093 回答