#! /bin/sh # /etc/logbackup.d/clean # logbackup fragment to clean unwanted logs # # This script allows rotation and backup of log files, # on systems where /var/log is mounted as tmpfs. # # It is called by /etc/init.d/logbackup: # - at system startup to retreive backed-up logs to /var/log # - on a daily basis to rotate and back-up the logs on the hard-drive # - at system halt or reboot to back-up the logs before the # tmpfs is unmounted # # This script removes unwanted logs to prevent their filling the entire # /var/log partition. NAME="clean" DIR_LOG="/var/log" DIR_BAK="/var/log.real" LOGS=" /var/log/aptitude /var/log/dpkg.log " # Rotate logs (in $DIR_LOG) do_rotate() { LOGS=`echo $LOGS` logger -i -t "logbackup" "($NAME) remove unwanted logs: $LOGS" rm -f $LOGS return 0 } do_retrieve() { return 0 } do_backup() { return 0 } case "$1" in retrieve) do_retrieve ;; backup) do_retrieve do_rotate do_backup ;; *) echo "Usage: $SCRIPTNAME {retrieve|backup}" >&2 exit 3 ;; esac