]> git.wh0rd.org - dump.git/blame - examples/remote_backup_ssh/backitup
Prepare for release 0.4b37
[dump.git] / examples / remote_backup_ssh / backitup
CommitLineData
ec617e1d
SP
1#!/bin/sh
2
3#
4# This script will backup local drives to a remote tape drive over ssh.
5# written by David B. Peterson <dave@toppledwagon.com>
6#
7# Follow these steps before using it the first time:
8# 1. Configure the env variables below, especially OPERATOR, TAPEHOST
9# TAPEDEV, and FILESYSTEMS
10# 2. run the following commands as root (on the machine to be backed up):
11# ssh-keygen -t dsa
12# cat ~/.ssh/id_dsa.pub | ssh OPERATOR@TAPEHOST 'cat - >> ~/.ssh/authorized_keys2'
13#
14# where OPERATOR and TAPEHOST are as you have defined below.
15
16# We will run under screen so you can come back to the backup, if you need to.
17if [ ! "$WINDOW" ]; then
18 exec screen $0
19 exit
20fi
21
22# ssh-agent allows us to backup securely without entering the passphrase so
23# many times. This version uses openssh v2.9
24if [ ! $SSH_AGENT_PID ]; then
25 echo Starting ssh-agent...
26 exec ssh-agent -- /bin/sh $0
27 exit
28fi
29
30OPERATOR=backup
31TAPEHOST=tapehost.example.com
32TAPEDEV=/dev/nst0
33RMT=/sbin/rmt
34RSH='/usr/bin/ssh'
35DATE=`date +%Y%m%d`
36DUMP='/sbin/dump 0auf'
37LOGDIR=/var/log/backup
38FILESYSTEMS='hda1 hda7 hda6 hda5 hda10'
39
40#### config above ####
41# backup FILESYSTEMS to the TAPEDEV on TAPEHOST with DUMP as OPERATOR using RSH
42
43export RMT RSH
44mkdir -p $LOGDIR &> /dev/null
45ssh-add ~/.ssh/id_dsa
46
47echo "Rewinding tape..."
48REWIND="mt -f $TAPEDEV rewind"
49$RSH $OPERATOR@$TAPEHOST $REWIND
50
51for FS in $FILESYSTEMS
52do
53 $DUMP $OPERATOR@$TAPEHOST:$TAPEDEV /dev/$FS 2>&1 | tee $LOGDIR/$FS.$DATE
54done
55
56echo "Rewinding and ejecting tape..."
57OFFLINE="mt -f $TAPEDEV offline"
58$RSH $OPERATOR@$TAPEHOST $OFFLINE
59