summaryrefslogtreecommitdiff
path: root/packaging/utils/backup
blob: 0c860c280bb18726b1577b80ef20cea4ea617b2a (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh
# make backup of FreeSwan repository
# -l	local build only, do not transmit

#scphost=freeswan@xs1.xs4all.nl
scphost=henry@adams.freeswan.org
scpdir=backup
pfile=~freeswan/etc/relpass
ppfile=~freeswan/etc/bpp

PATH=/bin:/usr/bin
export PATH
umask 077

tmpdir=~freeswan/tmp
tarname=freeswan.tar

. ~freeswan/setup

cd $tmpdir
rm -f $tarname $tarname.gz
touch $tarname

cd ~freeswan
tar -cf $tmpdir/$tarname `ls -a |
	egrep -v '^(\.|\.\.|archive|\.nobak|\.ssh|\.ssh2|tmp)$'`

cd $tmpdir
gzip -9 $tarname
ls -l $tarname.gz

if test " $1" = " -l"
then
	exit 0
fi

echo updating >notice

date
expect -nN -c "
	set scphost $scphost
	set scpdir $scpdir
	set pfile $pfile
	set ppfile $ppfile
	set tarname $tarname
	"'
	# canned procedure for scp copying
	proc scp {from to} {
		global p scphost scpdir
		spawn scp2 -p -q $from $scphost:$scpdir/$to
		set timeout -1
		expect {
		"word:" {
			set fname $pfile
			# fall out
		}
		{":} {
			set fname $ppfile
			# fall out
		}
		eof {
			puts "eofed!"
			return
		}}
		sleep 3
		set f [open $fname r]
		set p [read $f]
		close $f
		send "$p\r"
		expect "\n"
		expect eof
		wait
	}

	scp notice $tarname.gz
	scp $tarname.gz $tarname.gz
	# done'
date

rm -f $tarname.gz