Supported Operations
####################
+To reduce clutter, many of the examples here rely on ``cdb``'s ability to pull
+the default database from the ``$CDB`` environment variable. If that's not what
+you want, add ``--db ${DB}`` to the invocation of ``cdb``.
+
+
Initialize A Database
=====================
::
- cdb --db ${DB} init
+ cdb init
Observe A Path
==============
Add the checksum of a single path to the database. This will create a new
checksum and/or a new path identifier as needed and will bind them together. ::
- sha512sum $FILE | cdb --db ${DB} addh
+ sha512sum $FILE | cdb addh
Or, for all files under a path::
- find $DIR -type f -exec sha512sum {} \+ | cdb --db ${DB} addh
+ find $DIR -type f -exec sha512sum {} \+ | cdb addh
If we have a pile of digest files already, each of which contains digests of
paths relative to its location, we can generate a database, ``${DB2}`` from them
with the assistance of the ``cdb-util digest-relativize`` tool::
- find ${DIR} -type f -name SHA512SUMS -print0 | cdb-util drel --inul | cdb --db ${DB} addh
+ find ${DIR} -type f -name SHA512SUMS -print0 | cdb-util drel -1 | cdb addh
Revalidate A Path Observation
=============================
Measure the checksum of a path and confirm that the database already held that
observation. Reports unexpected files as well as mis-checksummed contents. ::
- sha512sum $FILE | cdb --db ${DB} verh
+ sha512sum $FILE | cdb verh
Or for all files under a path::
- find $DIR -type f -exec sha512sum {} \; | cdb --db ${DB} verh
+ find $DIR -type f -exec sha512sum {} \; | cdb verh
This processing of digest streams is to be preferred to verifying a digest
stream as generated by the database, e.g.::
- cdb --db ${DB} look \* | sha512sum -c
+ cdb look \* | sha512sum -c
because the former can be more informative in the case of mismatching digests
(specifically, the database can look for other paths that have the reported
digest). If it's easier to have the database generate the set of files, that
can be done::
- cdb --db ${DB} look \* --format '$u$z' --nul | xargs -0 sha512sum | cdb --db ${DB} verh
+ cdb look \* --format '$u$z' --nul | xargs -0 sha512sum | cdb verh
Add Missing Checksums
=====================
to the database::
xargs -0 sha512sum > ${DB}.new < ${DB}.new-files0
- cdb --db ${DB} addh < ${DB}.new
+ cdb addh < ${DB}.new
Using diff
----------
Indicate that some file contents are to be considered a lesser version of some
other contents::
- cdb --db ${DB} addsuper /old/path /new/path
+ cdb addsuper /old/path /new/path
After this command is run, ``domv`` will be willing to remove the ``/old/path``
entry from the database.
be recorded as well, to be subsequently added to the database::
find /source/path -type f -exec sha512sum {} \+ | \
- cdb --db ${DB} ingest --target /new/path --prune
+ cdb ingest --target /new/path --prune
This will produce a stream of shell commands to copy files given by ``find``
into the ``/new/path`` directory (using their basename therein). Passing
We can then prepare to prune duplicates and add unique files::
- cdb --db ${DB} ingest --prune --inplace --digest-log ${DB}.new2 < ${DB}.new > ${DB}.prune
+ cdb ingest --prune --inplace --digest-log ${DB}.new2 < ${DB}.new > ${DB}.prune
Add new files to the database with::
- cdb --db ${DB} addh < ${DB}.new2
+ cdb addh < ${DB}.new2
Inspect the pruning commands to be run, and then execute them with::