#!/bin/sh # Filename: inc_backup # Description: UNIX Incremental Backup script # This script will back up any files newer then a touch file located in / # and will log each file it backs up. Log files are overwritten once a week. # # 1) To use this script create the following directories # /usr/local/bin , /usr/local/logs # 2) Then execute the command # touch /.inc_mark # 3) Create a full backup of the dirs you want to do incremental backups for # using a command similar to the following # find /Users -print | cpio -pdumv /Volumes/Backup # 4) Schedule it using crontab, launchd or something similar, # History # PRomano 1/30/89 # PMcCann 10/4/05 for use on OSX #Enter the directories you want to back up on the following line #Change per local file systems... BACKUP_DIRS="/Users" #Enter the location of your backups, usually an external disk or #networked drive. BACKUP_TO="/Volumes/Backup" #Enter your LOG DIR LOGDIR="/usr/local/logs" PATH=/etc:/bin:/usr/bin:/usr/local/bin export PATH cd / DAY="`date +%a`" LOGFILE="$LOGDIR/inc.${DAY}" SYSTEM=`uname -n` echo "-------------------------------------------------------------------" >$LOGFILE echo "Starting Incremental Backups on `date` for $SYSTEM" >> $LOGFILE # Backup the necessary file systems. for FS in $BACKUP_DIRS do echo "Starting backup for $FS on `date`." >> $LOGFILE echo "The following files are being backed up" >> $LOGFILE find /$FS -newer /.inc_mark -depth -print >> $LOGFILE find /$FS -newer /.inc_mark -depth -print | cpio -pdum $BACKUP_TO done echo "Incremental Backups completed at `date` for $SYSTEM." >> $LOGFILE echo "------------------------------------------------------------------" >> $LOGFILE touch /.inc_mark