-
Notifications
You must be signed in to change notification settings - Fork 1
/
JoeDog testar
138 lines (118 loc) · 2.35 KB
/
JoeDog testar
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# cat joedog.sh
#!/bin/sh
# Author: Jeffrey Fulmer
# Email: http://www.joedog.org/support/
# Date: Wed Mar 14 14:36:10 EDT 2012
# -
# This script archives the system to 10.38.240.71:/export for
# bare metal restoration.
#
FQDN=$(/bin/hostname)
HOST=$(/bin/hostname -s)
MSCR="/export/$HOST/scratch"
MTMP="/export/$HOST/tmp"
TYPE=0
CONF="/usr/local/etc/excludes.conf"
EXCL=""
NFSD="10.37.72.44:/export"
#
# Read the exclude list from $CONF
if [[ -e $CONF ]] ; then
while read line ; do
chr=${line:0:1}
case $chr in
'#')
# ignore comments
;;
*)
#if [[ ! -z $line ]] ; then
if [[ ${#line} -gt 2 ]] ; then
if [[ -z $EXCL ]] ; then
EXCL="$line"
else
EXCL="$EXCL|$line"
fi
fi
;;
esac
done < $CONF
else
EXCL="/export /var/mail /var/log"
fi
#
# either -c or -n is required
while getopts "cn" opt ; do
case $opt in
c)
let TYPE=1
;;
n)
let TYPE=2
;;
esac
done
usage() {
cat << EOF
Usage: archiver [-c|-n]
Requires either a '-c' or a '-n' argument
-c create a CD Rom archive
-n create an NFS archive
EOF
exit 1
}
prep() {
mount=$(cat /proc/mounts | grep export)
if [[ -z $mount ]] ; then
echo "ERROR: /export is not mounted"
exit 1
fi
if [ ! -e /export/$HOST ] ; then
mkdir -p /export/$HOST
else
mv /export/$HOST /export/$HOST.off
echo "mkdir"
mkdir -p /export/$HOST
fi
if [ ! -e $MSCR ] ; then
mkdir -p $MSCR
fi
if [ ! -e $MTMP ] ; then
mkdir -p $MTMP
fi
}
cdrom_archive() {
echo "CD Rom Archive"
/usr/sbin/mondoarchive -OVi -d /export/$HOST -S $MSCR -T $MTMP -9 \
-G -p $HOST -s 700m -N -E "\"$EXCL\""
if [[ $? != 0 ]]; then
## If this is not invoked by TWS, then
## we should put a messaging device here
exit 1
else
rm -Rf /export/$HOST.off
fi
cp -f /var/cache/mindi/mondorescue.iso /export/$HOST/$HOST-rescue.iso
rm -Rf $MSCR
rm -Rf $MTMP
}
nfs_archive() {
echo "NFS Archive"
/usr/sbin/mondoarchive -OVn "$NFSD" -S $MSCR -T $MTMP -9 \
-G -p $HOST -s 2g -N -E "\"$EXCL\""
cp -f /var/cache/mindi/mondorescue.iso /export/$HOST-rescue.iso
rm -Rf /export/$HOST
}
case $TYPE in
0)
usage
;;
1)
prep
cdrom_archive
;;
2)
prep
nfs_archive
;;
esac
exit 0;