aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-06-26 19:14:01 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-06-26 19:16:43 +0300
commit380b7047132b7747999c2bca1164671f5fb8c604 (patch)
tree91c229d9d70deb5a6fd1144a20fa4aeb59784619
parent3932856031189f0c242483068cdd8eaf44429fc8 (diff)
downloadbeam-380b7047132b7747999c2bca1164671f5fb8c604.tar.gz
beam-380b7047132b7747999c2bca1164671f5fb8c604.tar.bz2
Provide a default log rotate hook.
* Makefile.am (build.sed): Define LOCALSTATEDIR and DATAROOTDIR. * beam.conf (openlog_hook): Initialize to beam_logrotate. * doc/beam.conf.5in: Document openlog_hook and its default. * lib/beam/common.in (beam_logrotate): New function.
-rw-r--r--Makefile.am2
-rw-r--r--beam.conf2
-rw-r--r--doc/beam.conf.5in12
-rw-r--r--lib/beam/common.in20
4 files changed, 35 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 8d8a4ca..685624c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,6 +35,8 @@ $(top_builddir)/build.sed: Makefile
echo 's|@''LIBDIR''@|${libdir}|g'; \
echo 's|@''BINDIR''@|${bindir}|g'; \
echo 's|@''LIBEXECDIR''@|${libexecdir}|g'; \
+ echo 's|@''LOCALSTATEDIR''@|${localstatedir}|g'; \
+ echo 's|@''DATAROOTDIR''@|${datarootdir}|g'; \
echo 's|@''PACKAGE_BUGREPORT''@|$(PACKAGE_BUGREPORT)|g'; \
echo 's|@''PACKAGE_NAME''@|$(PACKAGE_NAME)|g';\
echo 's|@''PACKAGE_STRING''@|$(PACKAGE_STRING)|g';\
diff --git a/beam.conf b/beam.conf
index e6a7403..244ada7 100644
--- a/beam.conf
+++ b/beam.conf
@@ -22,7 +22,7 @@ echo >&2 "$0: WARNING: using default configuration boilerplate"
# Commands listed in openlog_hook are run before opening the logfile. The
# most common use for this hook is to rotate an oversized logfile prior to
# opening it.
-openlog_hook=
+openlog_hook=beam_logrotate
# The prologue_hook is a list of commands to run before starting backup
# (or restore).
prologue_hook=
diff --git a/doc/beam.conf.5in b/doc/beam.conf.5in
index 840b75a..9aa571c 100644
--- a/doc/beam.conf.5in
+++ b/doc/beam.conf.5in
@@ -356,6 +356,18 @@ commands to be run before and after backup.
Commands listed in this variable are run before opening the logfile. The
most common use for this hook is to rotate an oversized logfile prior to
opening it.
+
+The default configuration file initializes this hook with
+.BR beam_logrotate ,
+a shell function that uses
+.BR logrotate (8)
+to manage the log file. Configuration for
+.BR logrotate (8)
+can be supplied in the
+.B backup_logrotate_conf
+variable. By default, the log file is rotated weekly, 4
+weeks worth of backlogs are preserved.
+.TP
.B prologue_hook
This variable contains a whitespace-separated list of commands to
be invoked before starting backup (or restore). These commands are
diff --git a/lib/beam/common.in b/lib/beam/common.in
index b9df1b0..e5ad7a6 100644
--- a/lib/beam/common.in
+++ b/lib/beam/common.in
@@ -185,3 +185,23 @@ EOF
cat $report
) | $backup_mailer_program
}
+
+beam_logrotate() {
+ local conf=/tmp/beam-logrotate.conf u
+ if test -z "$backup_logrotate_conf"; then
+ backup_logrotate_conf="weekly
+rotate 4
+"
+ fi
+ u=$(umask)
+ umask 077
+ cat > $conf <<EOF
+$backup_logfile {
+$backup_logrotate_conf
+}
+EOF
+ umask $u
+ test -d @LOCALSTATEDIR@/lib/beam || mkdir @LOCALSTATEDIR@/lib/beam
+ logrotate ${dry_run+-d} --state @LOCALSTATEDIR@/lib/beam/logrotate.state $conf
+ rm $conf
+}

Return to:

Send suggestions and report system problems to the System administrator.