#! /bin/sh # sender-incremental - send backup to ssh for remote sshbkp-receiver # Copyright (C) 2001 Berend de Boer # # -------------- put your email address here backuplackey=berend@pobox.com me=sender-incremental host=`hostname | sed 's/\..*//'` # -------------- replace "meili" with the hostname of the machine # where sshbkp-receiver will run. rhost=bmach key=/root/.ssh/sender # level level=1 previouslevel=`expr $level - 1` # ---------- print a mail header to make it easy to mail this # script's output with # "sender-full | /usr/lib/sendmail -t" # cat <&1 echo ' ------------' $0 echo ' ------------ starting backup on' `date` echo ' ------------ storage host:' $rhost # backup of other file systems with cpio # use a 5120 blocksize # use SRV4 portable format # ----------------- these lines are from df -k output for convenience, # and the a b c d variables are dummies. # while read dev a b c d mountpt; do echo ' ------------ backing up device:' $dev mount point: $mountpt # ------- name this backup after the mount point, # turning slashes to underscores, and removing the initial # slash. # fs=`echo $mountpt | sed -e 's/^\///' -e 's/\//_/g'` if [ "$fs" = "" ]; then fs=root fi title=${host}dump-$fs touchfile=$mountpt/DO_NOT_REMOVE.level.$level.cpio.touchfile previoustouchfile=$mountpt/DO_NOT_REMOVE.level.$previouslevel.cpio.touchfile touch $touchfile # ----------- send readable output to file descriptor six, where we # copied the standard output, since we're piping the dump # to ssh on standard output # (echo $title; find $mountpt -depth -path '*/.opera/cache4' -prune -or -path '*/core.*' -prune -or -path '*/.mozilla/*/Cache' -prune -or -path 'pub/' -prune -or -path 'mp3/' -prune -or -newer $previoustouchfile -print | /bin/cpio -B --create --reset-access-time -c) 2>&6 \ | dd ibs=32k obs=32k \ | ssh -T -i $key $rhost || { echo $me: Error: cpio $dev failed with $? 1>&2 exit 1 } # ---------- for convenience, we feed the loop with a "here document" # that contains lines from the output of "df -k" # done << EOF /dev/hda8 5112364 4908328 204036 97% /u3 /dev/hda9 4073212 3486372 586840 86% /u2 /dev/hda12 4073212 3486372 586840 86% /u2 EOF # backup of dumpable file systems # ----------------- these lines are from df -k output for convenience, # and the a b c d variables are dummies. # while read dev a b c d mountpt; do echo ' ------------ backing up device:' $dev mount point: $mountpt # ------- name this backup after the mount point, # turning slashes to underscores, and removing the initial # slash. # fs=`echo $mountpt | sed -e 's/^\///' -e 's/\//_/g'` if [ "$fs" = "" ]; then fs=root fi title=${host}dump-$fs # ----------- send readable output to file descriptor six, where we # copied the standard output, since we're piping the dump # to ssh on standard output # (echo $title; /sbin/dump -$level -u -q -f - $dev) 2>&6 \ | dd ibs=32k obs=32k \ | ssh -T -i $key $rhost || { echo $me: Error: dump $dev failed with $? 1>&2 exit 1 } # ---------- for convenience, we feed the loop with a "here document" # that contains lines from the output of "df -k" # done << EOF /dev/hda5 14607 7978 5875 58% /boot /dev/hda6 4033040 3324428 503740 87% / EOF #/dev/hda6 4033040 3324428 503740 87% / echo ' ------------ finishing backup on ' `date`