Rsyncing of block devices to a remote file

jw schultz jw at pegasys.ws
Thu Jan 23 09:52:01 EST 2003


On Thu, Jan 23, 2003 at 09:17:04AM +0100, David Heremans wrote:
> Hello,
> 
> I'm looking for some assistance in modifying the rsync code
> 
> Situation: I used to back-up some of my (unmounted NTFS) disk partitions
> remotely using the following shells construct:
> dd if=/dev/hda1 | gzip | ssh me at backupmachine 'cat >
> /backup-dir/hda1-backup.gz'
> 
> But now I want to use rsync for this, since transfering 10 gig takes a litle
> to long if a file of a few kB has changed :-). I looked trough the archive
> and found an old mail talking about the same problem, and a response
> explaining the problem of writting to a block device (since rsync writes a
> copy file and then moves it over the original). But the same mail also said
> that reading from it should be trivial, so I set out trying to implement
> this.
> 
> So I created a '--read-block-file' option in options.c and avoided the
> 'skipping non regular file' message in generator.c
> By altering all this the receiver is ready to get the data, but in the flist
> structure it still says that '/dev/hda1' is still a devicefile 
> and that the size is 0, and so the sender does send over zero bytes
> 
> Now here is the problem : How do I get the size of partition in this
> datastructure ? Or more generique, how would I handle this for /dev/fd0,
> since you can insert 1.44MB disks or 720kB disks ?
> 
> Anybody else tried to read blockdevices over rsync already ?
> 
> After all, sending the data of a block device doesn't seem to be as trivial
> as the archived mail sugested :-)

I do not believe that this is portable.  There may be ioctl
command(s) to retrieve this information.  Most likely you
will need to fetch block size and counts seperately and do
the artithmatic.  I recall indications that linux may
obsolete this method and moving this to sysfs or driverfs
but i could be mistaken.  In any event there is no
requirement that all OSs use the same method.  If you can't
find it in the documentation try looking at the source code
for a mkfs command for your OS or run one with a strace
supervisor.

Alternatively dd if=/dev/hda1 | gzip >hda1-backup.gz; rsync
hda1-backup.gz me at backupmachine/backup-dir/hda1-backup.gz
and you'll get much better results with the rsync friendly
patch to gzip.


-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt



More information about the rsync mailing list