#!/bin/bash
# Sticking:
# backup.sh >> logfile.txt 2>&1
#
# into your crontab should take care of this.
##############################################################################################
# Things to backup and their mountpoints
##############################################################################################
# Backups Directory
BACKUPS_DIR="/storage/backups/server"
SOURCES="./etc ./home ./opt ./root ./storage ./var/log"
##############################################################################################
# Begin
##############################################################################################
TS=`date +'%Y-%m-%d-%H%M%S'`
HOSTNAME=`hostname`
TARNAME="${BACKUPS_DIR}/${HOSTNAME}-${TS}.tar.bz2"
STARTTIME=`date`
echo -e "\n\n--------------------------------------------------------------------------------"
echo -e "\n$STARTTIME: Running $0"
echo -e "\n$STARTTIME: Beginning backup of server:"
echo " Backup up directories: $SOURCES"
echo " to: $TARNAME"
echo
echo
echo "---- Beginning Backup Operation ---"
date
cd /
tar cjf "${TARNAME}" --exclude=.${BACKUPS_DIR} ${SOURCES}
cd -
/root/bin/clean_old_files.pl ${BACKUPS_DIR}
echo
echo "---- Ending Backup Operation ---"
date
##############################################################################################
# __END__
##############################################################################################
Comments