File: weekly.new

package info (click to toggle)
tar 1.12-7
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,552 kB
  • ctags: 1,623
  • sloc: ansic: 15,401; sh: 898; yacc: 856; lisp: 592; makefile: 336; perl: 111; sed: 93
file content (42 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
# start doing things
TOBACKUP="albert:/"

HOST=`hostname | sed 's/\..*//'`
TAPEFILE=/dev/rfd0a
LOGFILE=tar-out
BLOCKING=20
TAR_PART1="/usr/local/bin/tar clbfVM $BLOCKING"

rm -f $LOGFILE

mt -f $TAPEFILE rewind

	host=`echo $TOBACKUP | sed 's/:.*$//'`;
	fs=`echo $TOBACKUP | sed 's/^.*://'`;
	date=`date`;
	fsname=`echo $TOBACKUP | sed 's/\//:/g'`

	TAR_PART2="'Weekly backup of $fs on $host at $date' -C $fs ."
	echo Backing up $TOBACKUP at $date | tee -a $LOGFILE

	# Actually back things up.

	if [ $HOST != $host ] ; then
		rsh $host $TAR_PART1 $HOST:$TAPEFILE $TAR_PART2
	else
		sh -c "exec $TAR_PART1 $TAPEFILE $TAR_PART2"
	fi
	if [ $? -ne 0 ] ; then
		echo Backup of $TOBACKUP failed. | tee -a $LOGFILE
		echo mts at time of failure | tee -a $LOGFILE
		mts -t $TAPEFILE | tee -a $LOGFILE
		# I'm assuming that the tar will have written an empty
		# file to the tape, otherwise I should do a cat here.
	else
		echo $date > $fsname.lasttar
	fi
	sleep 60;

mt -f $TAPEFILE rewind
mt -f $TAPEFILE offl