How to make a block-level incremental backup using LVM?

Alan Cox alan at lxorguk.ukuu.org.uk
Fri Dec 14 15:15:03 UTC 2012


> > A block dump doesn't even guarantee you can restore the volume unless its
> > an atomic snapshot of everything involved, including journals if they are
> > on another device.
> 
> Commercial tools promise this ability. How do they get the block-to-file 
> mapping to do the restore? I was looking for a way to do that so I could 
> do the same using LVM snapshots.

you cannot go block to file. To start with when restoring the block may
already have been reused for another file.

You can go file to block list, but thats only for some file systems and
not really reliable except for an unmounted snapshot.

> But LVM snapshots are a "whole" disk. If I try to backup them using dd 
> or rsync, they are the same as a full backup. How to backup just the 
> snapshot changed blocks and later restore them (of course after 
> restoring the full volume, or to a mirror)?

What the snapshot gives you is an atomic copy of the file system so you
can do a full file system copy, or backup the snapshot without the stuff
underneath changing. It's basically a way to get an unmounted, out of use
copy cheaply that you can then use for stuff.

> I really don't like a rsync-based backup because there's no way I can 
> check the backup files like I can using a tar backup. I try to have both 
> a tarball somewhere and a rsync "mirror" elsewhere. The problem is that 
> both are taking too long to complete and even longer to restore. I have 
> the same complaints about drdb: the only reliable way to check if the 
> copy is fine is comparing with the source.

Correct - the only way to check any copy is valid is by comparing the
original to the copy. That in fact (plus clever magic) is how rsync
works, so in effect the way to check if an rsync copy is valid is to try
and rsync it again.

Doing a set of sha or md5sums on the two sides and comparing the output
now and then ought to provide a further check.

> There has to be a better way to restore a few TB of backup consisting of 
> lots of small files. :-(

Is the issue backing up or restoring ? If it is backing up then it may be
possible to work out which blocks are different between two snapshots and
transfer just those. I don't know the innards of the LVM layer well
enough to know if there is a clever way to do that. I'm also not sure it
would help if the blocks are scattered about as it would still be a lot
of seeking.

Alan


More information about the users mailing list