schoppenhauer
schoppenhauer

Reputation: 421

A portable way of getting all Filesystem-Metadata of a file

I would like to unify my backups from several machines, but every filesystem stores different metadata for files. Like access times, permissions, the whole stat-struct for unix-systems, xattrs, etc.

Of course, there is probably no better way than just looking at the filesystem a file is saved, and querying the metadata accordingly. But I wonder whether there is a tool that does this in a portable way - it should detect the filesystem the file is on, and obtain all the metadata, so I can restore it (assuming the restore point is at an equal filesystem).

Something like this should be comparably easy to write if one knows all the filesystems out there, so I assume it already exists. Do you know such a thing?

Upvotes: 1

Views: 521

Answers (1)

Mecki
Mecki

Reputation: 132869

There exists no tool that would support all attributes of all existing file systems on earth. The tool that comes closest to your request is tar. GNU tar has support for extended attributes (xattr) and it also captures many NTFS attributes (not sure about the current state, 2009 some less used NTFS attributes were not captured), and it also captures many HFS(+) attributes on Mac. Apple's tar implementation (also open source) even captures resource forks on OS X, though Apple is moving away from resource forks, as of today, most attributes that were added the last couple of years are stored as extended attributes (xattr) on OSX, too (HFS+ has xattr support). So using an up-to-date version of tar will probably deliver the best results in capturing and restoring file metadata; ideally using the tar provided by the system (e.g. on OSX with HFS+, Apple's tar may deliver better results than GNU tar), otherwise GNU tar is already pretty good as a general purpose utility.

Upvotes: 2

Related Questions