archive-logs

Iteratively archive newline separated log files

git clone https://git.8pit.net/archive-logs.git

 1.Dd $Mdocdate: June 14 2020 $
 2.Dt ARCHIVE-LOGS 1
 3.Os
 4.Sh NAME
 5.Nm archive-logs
 6.Nd archive newline separated log files
 7.Sh SYNOPSIS
 8.Nm archive-logs
 9.Op Fl e Ar pattern
10.Op Fl k Ar percentage
11.Ar current
12.Ar archive
13.Sh DESCRIPTION
14The
15.Nm
16utility copies newline separated log data from a
17.Ar current
18logging directory to an
19.Ar archive
20directory.
21The utility iterates over all regular files in the current directory.
22A configurable percentage of lines is retained in the iterated files.
23The remaining lines are appended to equally named files in the archive and
24erased from the files in the current directory.
25This property allows iteratively invoking the utility on the same pair
26of directories.
27.Pp
28The utility operates under two central assumptions.
29First, it is assumed that no other program access any files in the given
30directories while
31.Nm
32is running.
33Second, the utility assumes that log files are appended.
34Based on the later assumption only older log file entries are copied to
35the archive while more recent entries are retained.
36.Pp
37The options are as follows:
38.Bl -tag -width Ds
39.It Fl e Ar pattern
40Exclude all files matching the given extended regular expression
41.Ar pattern .
42The pattern should match file paths relative to the current directory.
43.It Fl k Ar percentage
44Specify the
45.Ar percentage
46of lines to keep in the log files from the current directory.
47Defaults to 50 if unspecified.
48.El
49.Sh EXIT STATUS
50.Ex -std archive-logs
51.Sh AUTHORS
52.An Sören Tempel Aq Mt soeren@soeren-tempel.net
53.Sh CAVEATS
54The utility operates under the central assumption that no other software
55accesses the files in the given directories while it is running.