On Aug 31, 2005, at 11:20 AM, Thomas Bettler wrote:
Why not cp -a or whatever on osX?
resource forks, finder meta data, automatic restore, finder bless, remote backups.
here is the script i came up with today.
seems to work.
#!/bin/sh
# admin who receives mail
mailTo="woadmin < at > visualfood.ch ([email]woadmin < at > visualfood.ch[/email])"
# server name, no spaces please
server_name="TVMM"
# excludes, this is the list recommended for osx by apple
#excludes="/tmp /var /Volumes /dev /Network /etc /automount /.vol /mach /mach.sym /.DS_Store /.Trashes /TheFindByContentFolder /TheVolumeSettingsFolder"
excludes="/tmp /var /private/var/tmp /Volumes /dev /Network /etc /automount /.vol /mach /mach.sym /.DS_Store /.Trashes /TheFindByContentFolder /TheVolumeSettingsFolder"
# may not handle device files correctly, so better leave them out
exclude_options="--exclude-device-files"
# How long to keep changes. 1M = 1 month
maxage="2W"
# the source volume
src=/
# the destination volume
dst=/Volumes/hd2/
# Which program to invoke
program=rdiff-backup
# Some basic configuration options; see the manual
other_options="--force -v5 --print-statistics --override-chars-to-quote ''"
########################################################
# Perform backup #
########################################################
# Setup what's needed for status reporting.
test -f /var/${server_name}Daily || echo "${server_name} Daily backups" > /var/log/${server_name}Daily
echo "" >>/var/log/${server_name}Daily
echo "${server_name} Daily" `date` >>/var/log/${server_name}Daily
msg="Backup deemed successful."
appendStatus ()
{
msg="Backup failed."
echo " " $1 >>/var/log/${server_name}Daily
}
# Build a bunch of --exclude ... statements and construct
# a number of arguments to send to rdiff-backup.
for i in $excludes; do
exclude_options="$exclude_options --exclude $i"
done
options="$exclude_options $other_options"
# Make sure there is a valid place to put the data
if [ -e "$dst" ]; then
if [ ! -d "$dst" ]; then
echo "Strange: '$dst' exists, but is not a directory"
appendStatus "Backup on ${server_name} failed $dst exists but is not a directory"
exit 1
fi
echo "found $dst"
else
mkdir -p $dst
echo "created $dst"
fi
# Backup
echo "Doing this: $program $options $src $dst"
echo "Backing up $dst"
$program $options $src $dst
# How did it go?
if [ $? -eq 0 ]; then
# It went well; removing stuff older than maxage
$program --force --remove-older-than $maxage $dst
if [ $? -eq 0 ]; then
echo "Clean-up OK"
else
echo "running this failed (during clean-up):"
echo "$program --force --remove-older-than $maxage $dst"
appendStatus "Backup on ${server_name} failed to clean up: $program --force remove-older-than $maxage $dst"
fi
echo "recreating the symlinks and volumes from the exclude list"
cd "$dst"
echo "cd to $dst"
ln -s private/etc etc
ln -s private/var var
ln -s private/tmp tmp
mkdir dev Volumes Network
# bless the System Folder (OSX only), i've excluded this for now, because repeated backups failed with permission errors YMMV
#echo "blessing the system folder"
#bless -folder ${dst}System/Library/CoreServices -bootinfo /usr/standalone/ppc/bootx.bootinfo
else
# It failed; don't clean up
echo "running this failed:"
echo "$program $options $src $dst"
appendStatus "Backup on ${server_name} failed completely: $program $options $src $dst"
fi
if test "$msg" != "Backup deemed successful."
then
# If sendmail is configured on machine the following will send a mail to somebody
mail -s "${server_name} Daily System Backup" $mailTo <<EOF
This message comes from the Backup_Server.sh script on $server_name.
The daily backup of $server_name did not complete successfully.
$msg
Please refer to the /var/log/${server_name}Daily.log for further details.
EOF
fi
#============================ end ==================================
Cornelius Jaeger,
Member of Visual FOOD GmbH - Software and Multimedia Solutions
http://www.screenfood.ch
http://www.visualfood.ch
Moosstrasse 7
CH-6003 Lucerne
SWITZERLAND
Fon: +41 (0)41 21 0 21 41
Fax: +41 (0)41 21 0 21 43
iChat or AIM nelius < at > mac.com ([email]nelius < at > mac.com[/email])