ChecksumDB is a cross-platform (UNIX and Windows) utility for the generation, storage, and comparison of file hashes to guard against corruption. ChecksumDB also uses SQLite for its database, making manual queries easy. Download.
ChecksumDB can be built using GCC with the command line: gcc checksumdb.c -lsqlite3 -lgcrypt -ochecksumdb
On Windows, Cygwin is required as well as Cygwin packages libgcrypt-devel, libgcrypt (libgcrypt11), and libsqlite3-devel. DLL files required are: cygwin1.dll, cygsqlite3-0.dll, cyggcc_s-1.dll, cyggcrypt-11.dll, cyggpg-error-0.dll, cygintl-8.dll, and cygiconv-2.dll.
For Linux and Windows, libraries required for execution are libgcrypt and libsqlite3.
checksumdb -u /home/user/stuff
This will recursively scan all files in /home/user/stuff, compute the SHA256 hash of each file, and store them in /home/user/stuff/checksum.db. /home/user/stuff (the target directory) is a required argument for all operations below.
checksumdb -u /home/user/stuff
This will recursively scan all files in /home/user/stuff (working disk to database), compute hashes, and create a new scan record in /home/user/stuff/checksum.db. Additionally, each file will be compared to its existing database records. ChecksumDB follows the following algorithm:
In the second case, a warning is always printed to inform the user about the potentially corrupted file. -v or -vv modes (verbosity and extra verbosity, respectively) will print informational messages about the other cases as well.
checksumdb -s /home/user/stuff
In scan mode, the database is opened in read-only mode. This is designed for checking the integrity of backups or other files not in active use. This method works from the database to the disk, checking that every file in the database exists on the disk with a matching hash.
Typical usage is -u when files are in use on a computer, and then -s on backups. The intent is to periodically (e.g. monthly) run -u on a production system, with -s being used to verify backup mediums as needed.
checksumdb -e /home/user/stuff
Lists past scans: scan number, scan date and time, and the directory scanned.
checksumdb -h /home/user/stuff/file1.txt /home/user/stuff
Lists the file history for /home/user/stuff/file1.txt: The scans in which it was found, its size, the status of each scan, scan dates, and the history of last modified dates. For events, the following statuses are possible:
checksumdb -f /home/user/stuffdatabase.db -u /home/user/stuff
-f specifies a filename for the database. By default, the database is a file named checksum.db in the top level of the target directory specified. With -f, you can place the database elsewhere, including outside of the target directory entirely.
checksumdb -k 5 -u /home/stuff
-k nn prevents the database from growing too large after repeated scans by only retaining the last nn scans (including the current one). Must be used with -u.
checksumdb -# 34 -s /home/stuff
-# nn uses scan number nn when comparing the database against the files. The default is to use the most recent scan. A list of past scans can be obtained with -e (see above) and -# used to compare against an older scan.
checksumdb -v -u /home/stuff
-v (and -vv) are verbosity options to show additional information. -v will show output for all files, and -vv will show greater output, including actual hash values. If you are paranoid about file integrity, -v is a nice switch.