[comp.unix.programmer] backup and restore: what about device files?

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (06/02/91)

In article <1991May16.233149.15268@athena.mit.edu>, mlevin@jade.tufts.edu writes:

> I would appreciate some advice about the following.  When you use a
> backup and restore utility on a Unix system, does it backup and
> restore device files?

That depends on the utility.  BSD dump, for example, does; tar does not
(in any incarnation I am aware of, at least).  Depending on what you
are trying to do, sometimes one behavior is appropriate, sometimes the
other.

> If so, any ideas on how?  Is the info given by stat() enough to
> recreate the device file (using makenod() or something) for a
> restore?

Yes.

> Any information on getting the attributes of and then re-creating
> device files would be reatly appreciated.

stat(2) (and lstat(2), if you have it) on a device file will return the
device major/minor numbers in the st_rdev element; to recreate it you
hand the device number to mknod(2).

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

les@chinet.chi.il.us (Leslie Mikesell) (06/04/91)

In article <1991Jun1.213927.28705@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:

>That depends on the utility.  BSD dump, for example, does; tar does not
>(in any incarnation I am aware of, at least).  Depending on what you
>are trying to do, sometimes one behavior is appropriate, sometimes the
>other.

GNUtar can be told to do devices.  However, when you restore you
may or may not want the devices back, since the reason you are restoring
may be that all or part of the original machine is no longer working.
Since they usually don't change often it is a good idea to backup
/dev by itself and omit it from backups of the files.  If the machine
has a floppy disk, you can use cpio to save them there, and restore
only if the same kernel is restored back to the same or an identical
machine.

Les Mikesell
  les@chinet.chi.il.us