#!/bin/sh
#
# Make backups of target.home
#
# Full backup goes into /backup/target/full/
# Inrementals go into /backup/target/<dayofweek>
#
# Based on a script by tridge@linuxcare.com
#
# Written by Brian C. Lane <bcl@brianlane.com>
#

if /usr/bin/lockfile -r1 /var/lock/target_inc
  then 

  # Day of the week for incremental backup
  BACKUPDIR=`date +%A`

  # Remove last week's incremental directory
  rm -rf /backup/target/$BACKUPDIR

  # Make a backup of the current RPMs installed
  ssh root@target.home "rpm -qa > /etc/rpm_qa.txt"

  rsync -azv -e "ssh -C -c blowfish -x -P" --stats --delete -u \
  --backup --backup-dir=/backup/target/$BACKUPDIR \
  --suffix='' \
  --exclude "/proc/" \
  --exclude "lost+found/" \
  --exclude "/dev/" \
  --exclude "/mnt/" \
  --exclude "/bin/" \
  --exclude "/sbin/" \
  --exclude "/lib/" \
  --exclude "/tmp/" \
  --exclude "/usr/bin/" \
  --exclude "/usr/kerberos/" \
  --exclude "/usr/lib/" \
  --exclude "/usr/libexec/" \
  --exclude "/usr/sbin/" \
  --exclude "/usr/share/" \
  --exclude "/usr/X11R6/" \
  --exclude "/extra/" \
  root@target.home:/ /backup/target/full/

  # Remove lockfile
  rm -f /var/lock/target_inc

fi