Backup script from Jon Mills
ibiblio colleague and systems guru John Mills writes:
Here’s the script, called backup.sh:
[bash]
#! /bin/bash
# Definitions
DISK=disk1s1
DIR_NAME=jonmills
SOURCE=/Users/${DIR_NAME}/
DEST=/Volumes/Backup/${DIR_NAME}/
EXCLUDE=/var/log/backup/excludes.${DIR_NAME}
# Mount a disk by hand with disktool
/usr/sbin/disktool -m ${DISK}
# Wait for the disk to spin up, or else this won’t work
sleep 10
# Copy the files with rsync
/usr/bin/rsync -av \
–delete \
–delete-excluded \
–exclude-from=${EXCLUDE} \
${SOURCE} \
${DEST}
# Unmount the disk manually with disktool
/usr/sbin/disktool -u ${DISK}
[/bash]
crontab looks like this:
[code]
#
# min hour mday month wday command
# Run the script at 4:30 AM and mail me the log
30 4 * * * ~/.backup.sh 2>&1 | mail -s "Backup Log - `date`" _____@gmail.com
[/code]
1 Comment