Backing up data using tar

Glen Turner glen.turner at aarnet.edu.au
Wed May 14 22:12:09 CST 2003


Andrew Reid wrote:
> On Wed, May 14, 2003 at 09:22:20AM +0930, Martin Stacey wrote:
> 
> 
>>Is it safe to backup the dev directory using the tar or should I avoid doing
>>this?
> 
> 
> Exclude it. I don't think tar is stupid enough to try and write the
> contents of the device files to your archive, but device files are
> magical anyway. Backing them up doesn't really achieve anything. It
> might be a good idea to keep a copy of the MAKEDEV script handy,
> though.

"tar" does the right thing and archives devices as device
entries.  For example create a tar file with

   tar cf /test.tar /dev

and show its contents with

   tar tvf /test.tar

     ...
     brw-rw---- root/disk       3,0 2003-01-30 20:54:36 dev/hda
     brw-rw---- root/disk       3,1 2003-01-30 20:54:36 dev/hda1
     brw-rw---- root/disk      3,10 2003-01-30 20:54:36 dev/hda10
     brw-rw---- root/disk      3,11 2003-01-30 20:54:36 dev/hda11
     brw-rw---- root/disk      3,12 2003-01-30 20:54:36 dev/hda12
     brw-rw---- root/disk      3,13 2003-01-30 20:54:36 dev/hda13
     brw-rw---- root/disk      3,14 2003-01-30 20:54:36 dev/hda14
     brw-rw---- root/disk      3,15 2003-01-30 20:54:36 dev/hda15
     brw-rw---- root/disk      3,16 2003-01-30 20:54:36 dev/hda16
     brw-rw---- root/disk      3,17 2003-01-30 20:54:36 dev/hda17
     brw-rw---- root/disk      3,18 2003-01-30 20:54:36 dev/hda18
     brw-rw---- root/disk      3,19 2003-01-30 20:54:36 dev/hda19
     ...

You can see how the hard disk device is archived as block device
files (not the content of the block device).

When unpacking it depends on the user and permissions whether
the device entries in the /dev directory are restored or not.
If you restore as root then the /dev directory will be
recreated (and correctly as well).

    su
    cd /
    tar xpf /test.tar

Other special directories can be problematic, such as /proc
(which tar sees as real files).

Also be careful not to tar the tar-file (ie: exclude the
directory the tar file being created is in) .

-- 
  Glen Turner         Tel: (08) 8303 3936 or +61 8 8303 3936
  Network Engineer          Email: glen.turner at aarnet.edu.au
  Australian Academic & Research Network   www.aarnet.edu.au
-- 
  linux.conf.au 2004, Adelaide          lca2004.linux.org.au
  Main conference 14-17 January 2004   Miniconfs from 12 Jan

-- 
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.freenode.net
To unsubscribe from the LinuxSA list:
  mail linuxsa-request at linuxsa.org.au with "unsubscribe" as the subject



More information about the linuxsa mailing list