Question about in-place option.

Mickaël CANÉVET canevet at embl.fr
Wed Jun 22 06:47:20 MDT 2011


Hello,

I was wondering if there is a way top specify rsync to replace only
different block in case of in-place update.

When I rsync a huge binary file that change often to a Copy-On-Write
filesystem for backing it up (ZFS in my case, but I suppose that btrfs
will act the same way) ; rsync replaces the whole file even with
'--inplace' and so snapshots are inefficient.

If you update only modified blocks, snapshots on COW filesystem takes
far less space.

I tested with an ugly program I wrote that does that, and it works well.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    FILE *fp1;
    FILE *fp2;

    char *oldfile = argv[1];
    char *newfile = argv[2];

    fp1 = fopen(oldfile, "rb+");
    if(fp1 == NULL) {
        perror("failed to open 1");
        return EXIT_FAILURE;
    }

    fp2 = fopen(newfile, "rb");
    if(fp2 == NULL) {
        perror("failed to open 2");
        return EXIT_FAILURE;
    }

    int i1;
    int i2;

    while (fread(&i2, sizeof(i2), 1, fp2) != 0)
    {
        fread(&i1, sizeof(i1), 1, fp1);
        if (i1 != i2)
        {
            fseek(fp1, -sizeof(i1), SEEK_CUR);
            fwrite(&i2, sizeof(i2), 1, fp1);
            fflush(fp1);
        }
    }

    fclose(fp1);
    fclose(fp2);
    return EXIT_SUCCESS;
}

Is there a way to do that with rsync ?
If no, is there any chance that you implement that in a future version ?

Thanks a lot.

Mickaël

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/rsync/attachments/20110622/63212102/attachment.pgp>


More information about the rsync mailing list