[KLUG Members] Harddrive Imaging

Bruce Smith members@kalamazoolinux.org
19 Jan 2003 16:00:06 -0500


> >>     dd if=/dev/hda of=/dev/hdb
> >
> > Works great for hard drives, but if the hard drives are of a different
> > size, you're going to have problems.  Also not a good idea to do on a
> > (RW) partition of a running system.
> 
> How do you do this with dd for a running system? A "hot" backup, if you will?

The problem is "dd" does a sector by sector RAW copy.

Doing it on a live file system _could_ result in a corrupt system since
things are constantly changing on the filesystem.  If the beginning
tracks contain system information like inode & other file allocation
tables, and during the actual copying something changes on the
filesystem, now you have old file allocation information matched up with
a different file structure.  Not good.

The best way to do this is to do the copy at the file level, not the
sector level.  It can be done with standard *nix utilities like "tar",
"cpio", or even "cp -a".  That way the worst thing that could happen is
some file being accessed is skipped or isn't completely copied.  Much
better than having an inconsistent filesystem.  The files that are
constantly being changed are usually log files, and it's not a big deal
in most cases if they don't copy correctly.

However, it's best to shutdown services like databases and other servers
during the copy to ensure their important files care copied correctly.

One trick I do with small Postgresql databases is to dump the entire
database to a flat file before a backup.  That way the flat file is
backed up correctly, and I don't need to be concerned about the actual
database.  I'll reload the flat file if I need to restore.

A neat trick you can do with HP-UX is to "freeze" the filesystem at a
consistent state before (and during) a backup.  The system keeps
running, but all filesystem changes go into a journal.  When the backup
is done, you unfreeze the filesystem and the journal is rolled forward
and the filesystem is really updated.  That's one thing I haven't seen
for Linux yet (but I haven't really looked very hard for it).  Hopefully
it'll be a feature someday.  Anyone every hear of this being on any
filesystem's "todo" list?  (or "done" list? :)

--------------------------------------------
Bruce Smith                bruce@armintl.com
System Administrator / Network Administrator
Armstrong International, Inc.
Three Rivers, Michigan  49093  USA
http://www.armstrong-intl.com/
--------------------------------------------