0 Replies - 1210 Views - Last Post: 28 September 2005 - 12:53 PM

#1 zeethreedee  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 27-July 05

Basic System log backup

Posted 28 September 2005 - 12:53 PM

Description: Just make it into an executable file and run at the bash shell. eg: ./logbackup.sh Its easy to use and will check that you have super user statas before running.Does what it says on the tin. This script will create a logfiles in a backup folder and clean your old logs up. Each time you run it it will append the data from your log to the backup.
#!/bin/bash
# Legal: released under the GPL licence, with not warranty to the 
# full extent that the law provides.

# Backup your log files on a regular basis, add this script to 
# your cron jobs list.

# Please distribute this script as you see fit but credit where 
# credits due. 
# AUTHOR: Lawrence Goldstien <[email protected]>
# PROJECT: the linux script bible
# UNIX NAME: script-bible
# WWW: http://script-bible.sourceforge.net/

# Setting up variables

LOG_DIR=/var/log
BACKUP_DIR=/var/log/backup
ROOT_UID=0

# Run as root, of course.
if [ "$UID" -ne "$ROOT_UID" ]
then
   echo "You are not the god, you must r00t to run this script."
   exit $E_NOTROOT
fi

# CD to the system log directory
cd $LOG_DIR

# Make the backup directory
mkdir $BACKUP_DIR

# Append system messages to the backup
cat messages > $BACKUP_DIR/messages

# Append system messages to the backup
cat wtmp > $BACKUP_DIR/wtmp

# Fill logs with nothingness
cat /dev/null > $LOG_DIR/messages
cat /dev/null > $LOG_DIR/wtmp

# And your done
echo "Logs cleared, you're all done here."

# Quit
exit



Is This A Good Question/Topic? 0
  • +

Page 1 of 1