Package: bdchecker
readme 中文readme ENOverviewbdchecker (BackupData Checker) is a tool for checking personal cold backup data, helping you discover data corruption in timeWhy use itImagine that we have some data that needs to be cold backup, which may be the raw market data of a certain financial market that is compressed every day; or some electronic versions of classic movies owned by individuals; or some keys that are not used all year round; Let’s first list some options:Storage planStorage life spanSSDseveral years to more than ten yearsHDD10+ yearstape drive30+ yearspunched paperthousand of yearsCarved in stone (Luo Ji raised his crutch above his head and shouted solemnly)millions of yearsThere is no doubt that if you have enough financial resources to engrave the information on stone and store it properly, it should be very safe unless you are attacked by a dual-vector foil attack; but for individuals, the cost of reading information from stones should be far greater than the value of the data we need to save.So when considering the ease of reading and writing of data, there is no doubt that the hard disk is the most convenient; but this brings additional requirements, that is, we need to regularly check whether the data is corrupted, this is the reason why usebdcheckerInstalluse pippip install bdcheckerdownload from project'sReleases, and decompressUsagebdcheckerinclude 3 sub-commandgen: scan directory, recursively traverse to generate the hash information of allnewfiles in the directory, and place them in the.bdchecker.metafolder.clean: scan directory, clean deleted files from hash informationcheck: scan directory, Find corrupted files (note that this operation will calculate the hash value of all files, which is more time-consuming)Example directoryAssume that we currently have the following directory structuredata
├──── a.txt
├──── b.txt
└──── c
      ├──── c1.txt
      └──── c2.txtCommand: genGenerate hash infosbdchecker gen -d data -v 1-d: directory for which information needs to be generated-v: verbose levelAfter missiong completed, you can see console output:dump meta info to data/.bdchecker.meta/sha256.csvWhen there are no new files in the directory, repeatedly executing thegencommand will not actually generate the hash information of the file.Command: cleanremovedata/c/c2.txt, then runbdchecker clean -d data -v 1You can see in the last few lines of the log:clean missing file's meta info: c/c2.txt, which means that we have successfully cleaned the hash information corresponding to the file.Command: checkrunbdchecker check -d data -v 1The last line of the log appears:all check pass, which means there are no new/deleted files and all files are not corrupted.Now, let's modifya.text, write something randomly, and then run againbdchecker check -d data -v 1At this time, an error message appears in the log:check failed: a.txt, old hash: ..., cur hash: ..., indicating that the content ofa.txthas changed.Migration and comparisonThe hash information generated bybdcheckerwill be saved in the.bdchecker.metain the directory, so you can directly migrate the entire folder during migration.When there are already multiple backup data and no hash value has been generated; at this time, you can use thebdchecker gencommand to generate a hash value for each backup data, and then compare the two files. Since the generated file lines are already sorted, so you can directly use commands such asdifffor comparison.