Backing up Files with md5sum


Backing up Files with md5sum

When I have a directory I am going to be moving around a lot I use the following command to find all files, create checksums, sort in a file, and write to a file:

find . -type f -exec md5sum "{}" + | sort -k 2 \
>2016-04-18_photos2016-03_md5sums_barbet1tbB.chk

This should sit at the top level of the folder you are dealing with. I back up my photos month by month, for instance, and I keep one with each of my yyyy-mm style directories. I name it with the date I created it (2016-04-18), the folder it is backing up (photos2016-03), md5sums so I remember what it is, and which hard drive I created or checked it on (barbet1tbB). Programs like Google Photos may recompress or fiddle with the metadata of folders, so these are best when used for manual backups or uploaded to places like Amazon’s Cloud Drive.

To verify check files I then run this command from the directory holding the .chk file:

md5sum --quiet -c 2016-04-18_photos2016-03_md5sums_barbet1tbB.chk

This will always output that the checksum file itself is corrupted, but that is ok for our purposes. Run this command whenever you copy the folder to a new location to ensure that everything is intact.


comments powered by Disqus