I have disk with non-critical data on it (mostly movies, music, pictures, text files). Data is not important enough for me to back it up. However I'd like to keep a backup of the "metadata", ie for each file :

  • filename and location
  • filetype, size and modification date
  • signature of first KB (faster to compute, doesn't matter if it has a higher collusion rate than full hash, or doesn't account for corruption past first KB, it's just to identify "what was what" in cases where filetype, size and mdate may be similar)

So that if I lose the data due to a disk failing, I can know what was on the disk and where, and if I manage to get back files using fsck/foremost/etc... I can automatically put back most of the recovered files to their location using the signature/filetype/filesize.

So I make the following command metadata file output:

echo "$(stat -c'%n %s %b %i %Y' $1) $(file -bi $1) $(head -c1K $1 | md5sum)" >> "$2"

I see various possibilities :

  • Put all the files metadata into one textfile (find ./datamountpoint -exec metadata {} backup.txt \;), but there would be a lot of redundant data with the filenames.

  • Copy the tree structure and replace each file by its metadata, and put it into an archive.


find ./datamountpoint -type d -exec mkdir ./backup{} \;
find ./datamountpoint -type f -exec metadata {} ./backup/{} \;
tar cvf 'backup.tar' ./backup

But I don't know which would be the more efficient speed-wise, or if tar archive have limits in number files, lengths of filenames. Maybe there is a tool I am not aware of that already does what I want.

So, what would be the correct way to backup the structure and files metadata of a partition ?

  • 1
    Did you ever find a way to do this? – snapfractalpop Sep 9 '17 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.