OT: tar only directory structure

John Kodis kodis at mail630.gsfc.nasa.gov
Tue Apr 13 17:58:10 UTC 2004


On Tue, Apr 13, 2004 at 11:57:07AM -0500, Rob Freeman wrote:

> Is it possible to just tar only the directory structure of a mount?  We are
> looking into backing up the /home of a fedora box, but do not need the
> thousand of files in all the separate folders.  Just the directory structure
> and permissions.

Use the "find" command to list all the directories, bash's "pipe a
command into a file descriptor" feature to feed this list of files to
tar, and tar's "--no-recursion" flag to tell tar not to back up the
files in the directories.  Putting all this together, to back up the
contents of the current working directory, you could use a command
something like this:

    $ tar cf dirs.tar --no-recursion --files-from <( find . -type d )

-- 
John Kodis                                    Goddard Space Flight Center
kodis at mail630.gsfc.nasa.gov                      Greenbelt, Maryland, USA
Phone: 301-286-7376                                     Fax: 301-286-1771





More information about the users mailing list