sync of ordinary files from lvm snapshot fails with --sparse, 3.2.2pre2

Perry Hutchison pluto at agora.rdrop.com
Mon Jul 6 07:26:48 UTC 2020


Scott Mcdermott via rsync <rsync at lists.samba.org> wrote:

> Getting some puzzling errors doing the following backup procedure
> on a root filesystem that's on LVM, when using sparse flag:
>
> lvcreate --snapshot --name baksnap --size 3G /dev/vg0/root
> mount -o ro /dev/vg0/baksnap /var/tmp/snapmnt
> rsync -izaHx \
>     --delete --delete-excluded --delete-after \
>     --partial --inplace --sparse \
>     --numeric-ids --bwlimit=640k --rsh=ssh \
>     /var/tmp/snapmnt \
>     bakhost:/path/to/backups/root/
>
> This is causing the following errors:
>
> .d..t...... etc/lvm/archive/
> <f+++++++++ etc/lvm/archive/vg0_01748-450988166.vg
> <f+++++++++ etc/lvm/archive/vg0_01749-1953687750.vg
> .d..t...... etc/lvm/backup/
> <f..t...... etc/lvm/backup/vg0
> <f..t...... root/.bash_history
> <f..t...... etc/lvm/backup/vg0
> ERROR: etc/lvm/backup/vg0 failed verification -- update retained.
> <f..t...... root/.bash_history
> ERROR: root/.bash_history failed verification -- update retained.
> rsync error: some files/attrs were not transferred (see previous
> errors) (code 23) at main.c(1287) [sender=3.2.2pre2]
>
> It repeats the above as many times as I run it.  Simply removing the
> "--sparse" flag makes the error go away.
>
> This makes no sense to me in the first place, because I'm mounting the
> snapshot readonly, so how can it change during the copy (presumably
> this is why it fails verification)? And in the second place, I don't
> see how sparse flag would affect anything at all.  I'm using --sparse
> --inplace because I have large VM images on this filesystem, and
> transfers are sometimes interrupted.  However these are only very
> small text files showing the error (and again, they are in a readonly
> mount...)

I suspect rsync is implementing --sparse in the straightforward way:
whenever the sender reads a large sequence of all-zero bytes -- for
some definition of "large" -- the receiver does a seek forward of
that amount instead of writing the zeros.  This is exactly what is
wanted when the output file is new, but it is naive if the output
file already exists and is being updated in place.  In the latter
case, we either need to read the part of the output file that
we're about to seek over -- and overwrite anything that reads back
non-zero with zeros -- or we need to temporarily turn off --sparse
when the output file already exists.



More information about the rsync mailing list