Debian Codegraph @

examples/remote_backup_ssh/backitup

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 #
4 # This script will backup local drives to a remote tape drive over ssh.
5 # written by David B. Peterson <[email protected]>
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.
17 if [scip-shell system . . `[`. ! "$WINDOW" ]; then
18 exec screen $0
19 exit
20 fi
21
22 # ssh-agent allows us to backup securely without entering the passphrase so
23 # many times. This version uses openssh v2.9
24 if [scip-shell system . . `[`. ! $SSH_AGENT_PID ]; then
25 echoscip-shell system . . echo. Starting ssh-agent...
26 exec ssh-agent -- /bin/shscip-shell filesystem . . `/bin/sh`. $0
27 exit
28 fi
29
30 OPERATOR=backup
31 TAPEHOST=tapehost.example.com
32 TAPEDEV=/dev/nst0scip-shell filesystem . . `/dev/nst0`.
33 RMT=/sbin/rmtscip-shell filesystem . . `/sbin/rmt`.
34 RSH='/usr/bin/sshscip-shell filesystem . . `/usr/bin/ssh`.'
35 DATE=`datescip-shell system . . date. +%Y%m%d`
36 DUMP='/sbin/dump 0aufscip-shell filesystem . . `/sbin/dump 0auf`.'
37 LOGDIR=/var/log/backupscip-shell filesystem . . `/var/log/backup`.
38 FILESYSTEMS='hda1 hda7 hda6 hda5 hda10'
39
40 #### config above ####
41 # backup FILESYSTEMS to the TAPEDEV on TAPEHOST with DUMP as OPERATOR using RSH
42
43 export RMT RSH
44 mkdirscip-shell system . . mkdir. -p $LOGDIR > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
45 ssh-addscip-shell system . . ssh-add. ~/.ssh/id_dsa
46
47 echoscip-shell system . . echo. "Rewinding tape..."
48 REWIND="mt -f $TAPEDEV rewind"
49 $RSH $OPERATOR@$TAPEHOST $REWIND
50
51 for FS in $FILESYSTEMS
52 do
53 $DUMP $OPERATOR@$TAPEHOST:$TAPEDEV /dev/$FS 2>&1 | teescip-shell system . . tee. $LOGDIR/$FS.$DATE
54 done
55
56 echoscip-shell system . . echo. "Rewinding and ejecting tape..."
57 OFFLINE="mt -f $TAPEDEV offline"
58 $RSH $OPERATOR@$TAPEHOST $OFFLINE
59