.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dbutil 1" .TH dbutil 1 "2018-10-09" "Mail Avenger 0.8.5" "Mail Avenger 0.8.5" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dbutil \- database utility .SH "SYNOPSIS" .IX Header "SYNOPSIS" dbutil {\-d | \-\-dump} \fIdbfile\fR .PP dbutil {\-q | \-\-query} [\-t] \fIdbfile\fR \fIkey\fR .PP dbutil {\-u | \-\-update} [\-n] \fIdbfile\fR \fIkey\fR [\fIvalue\fR] .PP dbutil {\-x | \-\-delete} \fIdbfile\fR \fIkey\fR .PP dbutil \-t [\fIdate\fR | [+|\-]\fIinterval\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The dbutil program maintains a database of key-value pairs that can be queried and updated from the command line. For each such pair in the database, it also keeps an expiration time, so that unused entries can be purged from the database. dbutil must be given an option specifying in which mode to run the program. The following modes are available: .IP "\fB\-\-dump\fR (\fB\-d\fR)" 4 .IX Item "--dump (-d)" Prints the contents of the database. Each database entry is printed in one of the the following two formats, depending on whether the record has an expiration time: .RS 4 .Sp .RS 4 \&\fIkey\fR \fIvalue\fR .Sp \&\fIkey\fR \fIvalue\fR (\fIexpiration-time\fR) .RE .RE .RS 4 .RE .IP "\fB\-\-query\fR (\fB\-q\fR)" 4 .IX Item "--query (-q)" Prints the value of a particular key in the database. If the \fB\-t\fR flag is also specified, prints the expiration time of the record. In addition, the \fB\-\-expire\fR flag can be specified to update the expiration time on the record. Exits 0 if the key was found, 1 if the key was not in the database, or 2 if there is a system error. .IP "\fB\-\-update\fR (\fB\-u\fR)" 4 .IX Item "--update (-u)" Sets the value of a key in the database to a particular value. If no value is supplied, sets the value to the empty string (which is not the same as deleting the record). The \fB\-\-expire\fR flag can also be specified to set an expiration time on the record. .Sp Ordinarily, this option overwrites any previous value in the database. If the \fB\-n\fR option is supplied, dbutil will not overwrite a previously stored value in the database (and will not update the expiration time on the record). Exits 0 if the key was found, 1 if \&\fB\-n\fR was specified and the key was already in the database, or 2 if there is a system error. .IP "\fB\-\-expire\fR={\fIdate\fR | [+|\-]\fIinterval\fR}" 4 .IX Item "--expire={date | [+|-]interval}" This option can be specified in conjunction with \fB\-\-update\fR or \&\fB\-\-query\fR to set an expiration time on the record. The option has two formats. You can either specify an absolute time, as the number of seconds since Jan 1, 1970 \s-1GMT,\s0 or you can specify an offset from the current time with the format: .RS 4 .Sp .RS 4 [\fB+\fR|\fB\-\fR]\fIcount\fR\fIunits\fR .RE .RE .RS 4 .Sp Where \fB+\fR means in the future, \fB\-\fR means in the past, \fIcount\fR is a number, and \fIunits\fR is one of the following characters: .IP "\fBs\fR \- seconds" 4 .IX Item "s - seconds" .PD 0 .IP "\fBm\fR \- minutes" 4 .IX Item "m - minutes" .IP "\fBh\fR \- hours" 4 .IX Item "h - hours" .IP "\fBD\fR \- days" 4 .IX Item "D - days" .IP "\fBW\fR \- weeks" 4 .IX Item "W - weeks" .IP "\fBM\fR \- months" 4 .IX Item "M - months" .IP "\fBY\fR \- years" 4 .IX Item "Y - years" .RE .RS 4 .PD .Sp For example \fB\-\-expire=+36D\fR means the record will be deleted in 36 days. If you always look up \fIkey\fR with the command: .Sp .RS 4 \&\fBdbutil \-\-query \-\-expire=+36D\fR \fIkey\fR .RE .RE .RS 4 .Sp then the key will only expire if you do not look it up within 36 days. .Sp Note that dbutil keeps a sorted list of the records by time of last access. Thus, purging old records is not an inherently expensive operation, and happens automatically whenever you modify the database. .RE .IP "\fB\-\-nosync\fR (\fB\-N\fR)" 4 .IX Item "--nosync (-N)" Ordinarily, dbutil synchronously flushes the database file to disk after making any modifications, to minimize the window of vulnerability in which a crash could corrupt the database (if the \&\fB\-\-dbhome\fR option is not supplied). Synchronously flushing the database file is slow, however. This option suppresses that behavior, and can be used to build lookup tables efficiently. For example, you might have a script that builds a file \fIx.db\fR by issuing the following commands: .Sp .Vb 8 \& #!/bin/sh \-e \& rm \-f x.db~ \& dbutil \-Nu x.db~ key1 val1 \& dbutil \-Nu x.db~ key2 val2 \& # ... \& dbutil \-Nu x.db~ keyn valn \& dbutil \-u @ @ \& mv \-f x.db~ x.db .Ve .IP "\fB\-\-delete\fR (\fB\-x\fR)" 4 .IX Item "--delete (-x)" Deletes a particular key from the database (if the database contains the key). Exits 0 if the key was found, 1 if the key was not in the database, or 2 if there was a system error. .IP "\fB\-t\fR [\fIdate\fR|\fIinterval\fR]" 4 .IX Item "-t [date|interval]" With no options, prints the number of seconds since Jan 1, 1970, \s-1GMT.\s0 With an argument that takes the same format as \fB\-\-expire\fR, prints the expiration time as an absolute number of seconds since 1970. Not really a database function, but useful hen you want to store a timestamp in the database. .Sp Note that \fB\-t\fR can also be combined with the \fB\-\-query\fR option, in which case it causes dbutil to print the expiration time of the key, rather than its value. .PP dbutil attempts to minimize the damage from an inopportune crash by flushing the database file to disk whenever it is modified. However, there is still a small window in which your database can be irrevocably corrupted. This may be alright if you are just using the database to store \*(L"soft state\*(R". .PP If you want the database to be recoverable under any circumstances, you must use write-ahead logging, in which case dbutil needs to keep a directory with database logs, not just a single database file. The following option specifies where to keep the log files. It must be used in conjunction with the other options for each mode except \fB\-t\fR: .IP "\fB\-\-dbhome=\fR\fIdbhome\fR" 4 .IX Item "--dbhome=dbhome" Specifies that database log files should be kept in directory \&\fIdbhome\fR (which will be created if it does not already exist). Note that database files with relative pathnames will also be stored in this directory. It is highly recommended that you use relative pathnames so as to store database files and log files together. Otherwise, you run the risk of accessing a logged database without the \&\fB\-\-dbhome\fR option and trashing its contents. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .IP "\fB\s-1DB_HOME\s0\fR" 4 .IX Item "DB_HOME" When set, specifies a directory in which to keep log files, so as to make the database crash-recoverable. This is equivalent to specifying the option \fB\-\-dbhome=$DB_HOME\fR (except that any actual \fB\-\-dbhome\fR argument will override the environment variable). .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBavenger\fR\|(1) .PP The Mail Avenger home page: . .SH "BUGS" .IX Header "BUGS" If you do not use the \fB\-\-dbhome\fR option or \fB\s-1DB_HOME\s0\fR environment variable and your machine crashes at the wrong time, you can lose your whole database. .PP The \fB\-\-dbhome\fR may or may not work if the directory is stored on \s-1NFS\s0; it depends on the \s-1NFS\s0 implementation. .PP If you access the database from multiple machines simultaneously, you will likely corrupt the database. Accessing from multiple processes on one machine is fine, because dbutil does locking. .PP If you ever access the same database file with and without the \&\fB\-\-dbhome\fR option (or \fB\s-1DB_HOME\s0\fR), you will probably irrevocably trash it. For that reason, databases with relative pathnames are actually stored in the log directory. .SH "AUTHOR" .IX Header "AUTHOR" David Mazie\*`res