archive-logs

Iteratively archive newline separated log files

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

 1# archive-logs
 2
 3Iteratively archive newline separated log files.
 4
 5## Status
 6
 7I actively use this software for archiving [hii][hii github] chat logs.
 8For this purpose it currently works entirely fine as is.
 9
10## Usage Example
11
12Consider the file `/var/log/messages` with the following content:
13
14	Jun  2 10:27:05 somehost syslog.info syslogd exiting
15	Jun  2 10:28:05 somehost syslog.info syslogd started
16
17Running `archive-logs -k 50 /var/log /mnt/nfs/archive/logs` will
18cause 50% of the data in `/var/log/messages` to be retained and the
19other 50% to be archived in `/mnt/nfs/archive`. The utility will only
20archive old data. As such, a file called `/mnt/nfs/archive/messages`
21will exist after the invocation with the following content:
22
23	Jun  2 10:27:05 somehost syslog.info syslogd exiting
24
25The existing log file `/var/log/messages` will be truncated to only
26store recent data, i.e. its content will be the following:
27
28	Jun  2 10:28:05 somehost syslog.info syslogd started
29
30## Installation
31
32The software can be compiled using:
33
34	make
35
36The software makes heavy use of the Linux `sendfile(2)` system call. If
37this system call is available it is highly desirable to compile with
38`HAVE_SENDFILE=1`. By default a compatibility function is used which
39emulates the sendfile system call in userland.
40
41After compilation, tests can be run using:
42
43	make check
44
45The software can be installed globally using:
46
47	make install
48
49## License
50
51This program is free software: you can redistribute it and/or modify it
52under the terms of the GNU General Public License as published by the
53Free Software Foundation, either version 3 of the License, or (at your
54option) any later version.
55
56This program is distributed in the hope that it will be useful, but
57WITHOUT ANY WARRANTY; without even the implied warranty of
58MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
59Public License for more details.
60
61You should have received a copy of the GNU General Public License along
62with this program. If not, see <http://www.gnu.org/licenses/>.
63
64[hii github]: https://github.com/nmeum/hii