Let’s say you moved a directory of files from Linux to your FAT32 pen drive temporarily. The ownership, permissions etc. of the contents would be lost. What if you want to retain them along with the data? metastore is another useful tool than can be added to our list of filesystem metadata backup utilities.
metastore works with files, directories and links in a file tree. It can backup and restore the following attributes of a file:
- modification time (optional)
metastore can also
- show stored and current metadata diff to track any modificaitons
- recreate missing empty directories
- remove extra empty directories
The intention of writing metastore was to cover for the limitation of git, which does not store metadata.
metastore is available in the default Ubuntu repos. However, the version is dated and the utility got several updates recently. Run the following commands to fetch the latest development version and compile it on Ubuntu:
$ sudo apt-get install libbsd-dev $ git clone https://github.com/przemoc/metastore $ cd metastore $ make $ sudo make install
$ metastore --help Usage: metastore ACTION [OPTION...] [PATH...] Where ACTION is one of: -c, --compare Show differences between stored and real metadata -s, --save Save current metadata -a, --apply Apply stored metadata -d, --dump Dump stored (if no PATH is given) or real metadata (if PATH is present, e.g. ./) in human-readable form -V, --version Output version information and exit -h, --help Help message (this text) Valid OPTIONS are: -v, --verbose Print more verbose messages -q, --quiet Print less verbose messages -m, --mtime Also take mtime into account for diff or apply -e, --empty-dirs Recreate missing empty directories -E, --remove-empty-dirs Remove extra empty directories -g, --git Do not omit .git directories -f, --file=FILE Set metadata file (./.metadata by default)
Create a meatadata (with modification time) backup of current directory in a specific file (default ./.metadata):
$ metastore --s . -f output
Restore the metadata:
$ metastore -a -m . -f output