Last active
May 25, 2017 14:12
-
-
Save gwpl/20aa3c8c1daa98619cd8f733a0326cb5 to your computer and use it in GitHub Desktop.
Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage. ( And yes, I know that this find command will not properly encode filenames containing quotes according to csv standard )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage. | |
fullpath="${1:-$PWD}" | |
dest="${2:-"$fullpath"/basic_files_metadata.csv.gz}" | |
hostname="${3:-"$(hostname)"}" | |
echo "find \"${fullpath}\" -type f -exec stat --format=\"%i,%Y,%s,%m,%n\" \"{}\" \\; > \"${dest}\"" | |
echo "Progress in lines generated:" | |
(echo "inode,modification_ts,size,hostname,mount,path"; | |
find "${fullpath}" -type f -exec stat --format="%i,%Y,%s,${hostname},%m,%n" "{}" \; | |
) | pv -l | gzip > "${dest}" | |
echo -n Finished: | |
ls -lha "${dest}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment