.\" $Revision: 1.14 $
.TH NEWS-RECOVERY 8
.SH NAME
makeactive, makehistory, newsrequeue \- tools to recover Usenet databases
.SH SYNOPSIS
.B makeactive
[
.B \-m
]
[
.B \-o
]

.B makehistory
[
.B \-b
]
[
.BI \-f " filename"
]
[
.B \-i
]
[
.B \-n
]
[
.B \-o
]
[
.B \-r
]
[
.BI \-s " size"
]
[
.BI \-T " tmpdir"
]
[
.B \-u
[
.B \-v
]
]

.B newsrequeue
[
.BI \-a " active"
]
[
.BI \-h " history"
]
[
.BI \-d " days"
]
[
.B \-l
]
[
.BI \-n " newsfeeds"
]
[
.I input
]
.SH DESCRIPTION
.I Makeactive
invokes
.IR find (1)
to get a list of all directories in the news spool tree,
.\" =()<.IR @<_PATH_SPOOL>@ .>()=
.IR /var/spool/news .
It discards directories named
.I lost+found
as well as those that have a period in them.
It scans all other directories for all-numeric filenames and determines
the highest and lowest number.
The program's output is a set of
.IR active (5)
file lines.
Because there is no way to know if a group is moderated or disabled,
the fourth field of all entries will be
.IR y .
Also, mid-level directories that aren't newsgroups will also created as
newsgroups with no entries (for example, there is a ``comp.sources.unix''
group, but no ``comp.sources'').
.PP
If the ``\-o'' flag is used,
.I makeactive
will read an existing
.I active
file for the list of group names and just renumber all groups.
It will preserve the fourth field of the
.I active
file if one is present.
This is analogous to the
.IR ctlinnd (8)
\&``renumber'' command, except that
.IR innd (8)
should throttled or not running.
Do not use this flag with output redirected to the standard active file!
.PP
If the ``\-m'' flag is given, then
.I makeactive
will attempt to adjust the highest and lowest article numbers wherever
possible.
If articles are found in a newsgroup, the numbers will reflect what
what was found.
If no articles are found in a newsgroup, the high number from the old
file will be kept, and the low number will be set to one more then
the high number.
This flag may only be used if the ``\-o'' flag is used.
.PP
.I Makeactive
exits with non-zero status if any problems occurred.
A typical way to use the program is with the following
.I /bin/sh
commands:
.RS
.DT
.nf
ctlinnd throttle "Rebuilding active file"
.\" =()<.ds R$ @<_PATH_ACTIVE>@>()=
.ds R$ /usr/lib/news/active
.\" =()<TEMP=${TMPDIR-@<_PATH_TMP>@}/act$$>()=
TEMP=${TMPDIR-/tmp}/act$$
if [ \-f \*(R$ ] ; then
    if makeactive \-o >${TEMP} ; then
        mv ${TEMP} \*(R$
    f\&i
else
    if makeactive >${TEMP} ; then
        # Edit to restore moderated
        # and aliased groups.
        \&.\|.\|.
        mv ${TEMP} \*(R$
    f\&i
f\&i
ctlinnd reload active "New active file"
ctlinnd go ''
.fi
.RE
.PP
.I Makehistory
rebuilds the
.IR history (5)
text file and the associated
.IR dbz (3)
database.
The default name of the text file is
.\" =()<.IR @<_PATH_HISTORY>@ ;>()=
.IR /usr/local/news/history ;
to specify a different name, use the ``\-f'' flag.
.I Makehistory
scans the
.IR active (5)
file to determine which newsgroup directories within the spool directory,
.\" =()<.IR @<_PATH_SPOOL>@ ,>()=
.IR /var/spool/news ,
should be scanned.
(If a group is removed, but its spool directory still exists,
.I makehistory
will ignore it.)
The program reads each file found and writes a history line for it.
If the ``\-b'' flag is used, then
.I makehistory
will remove any articles that do not have valid Message-ID headers in them.
.PP
After the text file is written,
.I makehistory
will build the
.I dbz
database.
If the ``\-f'' flag is used, then the database files are named
.I file.dir
and
.IR file.pag .
If the ``\-f'' flag is not used, then a temporary link to the name
.I history.n
is made and the database files are written as
.I history.n.pag
and
.IR history.n.dir .
If the ``\-o'' flag is used, then the link is not made and any existing
history files are overwritten.
If the old database exists,
.I makehistory
will use it to determine the size of the new database.
To ignore the old database use the ``\-i'' flag.
Using the ``\-o'' flag implies the ``\-i'' flag.
The program will also ignore any old database if the ``\-s'' flag is used
to specify the approximate number of entries in the new database.
Accurately specifying the size is an optimization that will create a more
efficient database.
(The size should be the estimated eventual size of the file, typically
the size of the old file.)
For more information, see the discussion of
.I dbzfresh
and
.I dbzsize
in
.IR dbz (3).
.PP
If the ``\-u'' flag is given, then
.I makehistory
assumes that
.I innd
is running.
It will pause the server while scanning, and then
send ``addhist'' commands (see
.IR ctlinnd (8))
to the server for any article that is not found in the
.I dbz
database.
The command ``makehistory\ \-bu'' is useful after a system crash, to delete
any mangled articles and bring the article database back into a more
consistent state.
If the ``\-v'' flag is used with the ``\-u'' flag, then
.I makehistory
will put a copy of all added lines on its standard output.
.PP
To scan the spool directory without rebuilding the
.I dbz
files, use the ``\-n'' flag.
If used with ``-u'', the server will not be paused while scanning.
To just build the
.I dbz
files from an existing text file, use the ``\-r'' flag.
The ``\-i'' or ``\-s'' flags can be useful if there are no valid
.I dbz
files to use.
A typical way to use this program is with the following
.I /bin/sh
commands:
.RS
.nf
ctlinnd throttle "Rebuilding history file"
.\" =()<cd @<_PATH_NEWSLIB>@>()=
cd /usr/lib/news
if makehistory \-n \-f history.n ; then
    :
else
    echo Error creating history file!
    exit 1
f\&i
# The following line can be used to retain expired history
# It is not necessary for the history file to be sorted.
# awk 'NF==2 { print; }' <history >>history.n
# View history file for mistakes.
if makehistory \-r \-s `wc \-l <history` \-f history.n; then
    mv history.n history
    mv history.n.dir history.dir
    mv history.n.pag history.pag
f\&i
ctlinnd go ''
.fi
.RE
.PP
.I Makehistory
needs to create a temporary file that contains one line for each article
it finds, which can become very large.
This file is created in the
.\" =()<.I @<_PATH_TMP>@>()=
.I /tmp
directory.
The ``TMPDIR'' environment variable may be used to specify a
different directory.
Alternatively, the ``\-T'' flag may be used to specify a temporary directory.
In addition, the
.IR sort (1)
that is invoked during the build writes large temporary files (often to
.IR /var/tmp
but see your system manpages).
If the ``\-T'' flag is used, then the flag and its value will be passed to
.IR sort .
On most systems this will change the temporary directory that
.I sort
uses.
if used, this flag and its value will be passed on to the
.IR sort (1)
command that is invoked during the build.
.PP
.I Makehistory
does not handle symbolic links.
If the news spool area is split across multiple partitions, the following
commands should probably be run before the database is regenerated:
.RS
.nf
.\" =()<cd @<_PATH_SPOOL>@>()=
cd /var/spool/news
find . -type l -name '[1-9]*' -print | xargs -t rm
.fi
.RE
Make sure to run the command on all the appropriate partitions!
.PP
.I Newsrequeue
can be used to rewrite batchfiles after a system crash.
It operates in two modes.
In the first mode, it first reads the
.I active
and
.IR newsfeeds (5)
files to determine where the different newsgroups are to be distributed.
To specify alternate locations for these files, use the ``\-a'' or ``\-n''
flags.
It then opens the
.I history
database.
To specify a different file, use the ``\-h'' flag
.PP
Once the files are opened,
.I newsrequeue
reads from the specified
.I input
file, or standard input if no file is specified.
Each line should have a single Message-ID, surrounded in angle brackets;
any other text on the line is ignored.
For example, the history file (or trailing subset of it) is acceptable
input to the program operating in this mode.
If the ``\-d'' flag is used, then only articles that were received
within the specified number of
.I days
will be processed.
.PP
.I Newsrequeue
uses the first two fields of the
.I newsfeed
entry \(em the sitename and the excludes field, and the patterns and
distribs field.
It ignores all flags in the third field except for the ``N'' field, and
also ignores the fourth field altogether.
.PP
The second mode is used if the ``\-l'' flag is used.
In this mode, it reads from the specified
.I input
file, or standard input if no file is specified.
Each line should look like an
.I innd
log entry.
It parses entries for accepted articles, looks up the Message-ID in the
history database to get the filename, and then scans the list of
sites.
.PP
In either mode, the output of
.I newsrequeue
consists of one line for each article that should be forwarded.
Each such line contains the Message-ID, the filename, and the list of
sites that should receive the article.
The output is suitable for piping into
.IR filechan (8).
.SH HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews.
.de R$
This is revision \\$3, dated \\$4.
..
.R$ $Id: news-recovery.8,v 1.14 1993/03/18 21:03:41 rsalz Exp $
.SH "SEE ALSO"
active(5),
ctlinnd(8),
dbz(3),
filechan(8),
history(5),
innd(8),
newsfeeds(5).
