Révision 49
bin/enable-replica (revision 49) | ||
---|---|---|
4 | 4 |
DIR_CONF_REPLICA="/opt/gZFS/replicas/" |
5 | 5 |
DIR_CRON="/etc/cron.d/" |
6 | 6 |
BIN_ZFS_REPLICA="/sbin/zfs-replica" |
7 |
BINZFS="/sbin/zfs" |
|
8 |
BINZPOOL="/sbin/zpool" |
|
7 | 9 |
|
8 | 10 |
# TODO: traduire les msg |
9 | 11 |
|
... | ... | |
43 | 45 |
} |
44 | 46 |
|
45 | 47 |
function interactive { |
46 |
zfs list
|
|
48 |
$BINZFS list
|
|
47 | 49 |
echo "*** Select the ZFS volume/filesystem to replicate : ***" |
48 | 50 |
|
49 | 51 |
while read inputline |
... | ... | |
67 | 69 |
done |
68 | 70 |
if [ "$inputConfirm" = "y" ] |
69 | 71 |
then |
70 |
zfs list $volfs
|
|
72 |
$BINZFS list $volfs
|
|
71 | 73 |
if [ $? -eq 0 ] |
72 | 74 |
then |
73 | 75 |
echo "*** The ZFS volume/filesystem selected $volfs exists ***" |
bin/get-provisioned-space (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 |
BINZFS="/sbin/zfs" |
|
4 |
BINZPOOL="/sbin/zpool" |
|
3 | 5 |
|
4 | 6 |
function usage { |
5 | 7 |
echo "Syntax: $0 zfs_volume_name"1>&2 |
... | ... | |
11 | 13 |
usage |
12 | 14 |
else |
13 | 15 |
|
14 |
/sbin/zfs get volsize -H -t volume |egrep $1
|
|
15 |
/sbin/zfs get referenced -H $1
|
|
16 |
$BINZFS get volsize -H -t volume |egrep $1
|
|
17 |
$BINZFS get referenced -H $1
|
|
16 | 18 |
fi |
bin/create-volume (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 | 3 |
|
4 |
BINZFS="/sbin/zfs" |
|
5 |
BINZPOOL="/sbin/zpool" |
|
6 |
|
|
4 | 7 |
function usage { |
5 | 8 |
echo "Syntax :" 1>&2 |
6 | 9 |
echo "$0 [options]" 1>&2 |
... | ... | |
8 | 11 |
echo " -p : pool name" 1>&2 |
9 | 12 |
echo " -b : block size. Permit value : 32K, 64K, 128K (recommanded)" 1>&2 |
10 | 13 |
echo " -s : volume size. Permit unit : T, G, M" 1>&2 |
11 |
# FIXME: c'est pas clair ta formulation |
|
12 | 14 |
echo " -o : set property list for a zfs volume. Separate such property by a ','." 1>&2 |
13 | 15 |
echo " Example : -o compression=off,snapdev=visble." 1>&2 |
14 | 16 |
echo " Read the man zfs to get the list of the valid properties" 1>&2 |
... | ... | |
20 | 22 |
|
21 | 23 |
if [[ -z $VOL_OPTION ]] |
22 | 24 |
then |
23 |
/sbin/zfs create -s -b $BLOCK_SIZE -V $SIZE $NAME_POOL/$NAME
|
|
25 |
$BINZFS create -s -b $BLOCK_SIZE -V $SIZE $NAME_POOL/$NAME
|
|
24 | 26 |
else |
25 |
/sbin/zfs create -s -b $BLOCK_SIZE -o $VOL_OPTION -V $SIZE $NAME_POOL/$NAME
|
|
27 |
$BINZFS create -s -b $BLOCK_SIZE -o $VOL_OPTION -V $SIZE $NAME_POOL/$NAME
|
|
26 | 28 |
fi |
27 | 29 |
|
28 | 30 |
} |
29 | 31 |
|
30 | 32 |
|
31 | 33 |
function interactive { |
32 |
/sbin/zfs list
|
|
34 |
$BINZFS list
|
|
33 | 35 |
echo "*** Select the parent zpool : ***" |
34 | 36 |
|
35 | 37 |
while read inputline |
36 | 38 |
do |
37 | 39 |
if [ "$inputline" != "" ] |
38 | 40 |
then |
39 |
/sbin/zfs list |grep -i $inputline
|
|
41 |
$BINZFS list |grep -i $inputline
|
|
40 | 42 |
if [ $? -eq 1 ] |
41 | 43 |
then |
42 | 44 |
echo "*** Select the parent zpool ***" |
... | ... | |
84 | 86 |
do |
85 | 87 |
if [ "$inputSize" != "" ] |
86 | 88 |
then |
87 |
/sbin/zfs create -s -b 128K -V $inputSize $NAME_POOL/$inputVolume
|
|
89 |
$BINZFS create -s -b 128K -V $inputSize $NAME_POOL/$inputVolume
|
|
88 | 90 |
if [ $? -eq 0 ] |
89 | 91 |
then |
90 | 92 |
echo "*** ZFS volume creation [OK] ***" |
91 |
/sbin/zfs list
|
|
93 |
$BINZFS list
|
|
92 | 94 |
break |
93 | 95 |
else |
94 | 96 |
echo "/!\\ ZFS volume creation [ERROR] /!\\" |
bin/get-disk-zpool (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 | 3 |
|
4 |
BINZFS="/sbin/zfs" |
|
5 |
BINZPOOL="/sbin/zpool" |
|
6 |
|
|
4 | 7 |
function usage { |
5 | 8 |
|
6 | 9 |
echo "Syntax $0" |
... | ... | |
26 | 29 |
if [ "$property" == "name" ] |
27 | 30 |
then |
28 | 31 |
echo "$property:$valueProperty" |
29 |
echo "$(/sbin/zpool status $valueProperty|grep -i "state:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")"
|
|
30 |
echo "$(/sbin/zpool status $valueProperty|grep -i "scan:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")"
|
|
32 |
echo "$($BINZPOOL status $valueProperty|grep -i "state:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")"
|
|
33 |
echo "$($BINZPOOL status $valueProperty|grep -i "scan:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")"
|
|
31 | 34 |
poolname="$valueProperty" |
32 | 35 |
fi |
33 | 36 |
if [[ "$property" =~ "children[" ]] |
bin/del-volume (revision 49) | ||
---|---|---|
2 | 2 |
# $Id$ |
3 | 3 |
|
4 | 4 |
# TODO: fix typos |
5 |
|
|
6 | 5 |
GETINFO_ISCSI="/sbin/get-conf-iscsi-volume" |
7 | 6 |
DEL_ISCSI="/sbin/del-iscsi-volume" |
7 |
BINZFS="/sbin/zfs" |
|
8 |
BINZPOOL="/sbin/zpool" |
|
8 | 9 |
|
9 | 10 |
function usage { |
10 | 11 |
echo "Usage :" 1>&2 |
... | ... | |
21 | 22 |
|
22 | 23 |
if [ "$TID" == "" ] |
23 | 24 |
then |
24 |
zfs destroy -r $NAME_VOL
|
|
25 |
$BINZFS destroy -r $NAME_VOL
|
|
25 | 26 |
|
26 | 27 |
else |
27 | 28 |
$DEL_ISCSI -T $TID |
28 | 29 |
if [ $? -eq 0 ] |
29 | 30 |
then |
30 |
zfs destroy -r $NAME_VOL
|
|
31 |
$BINZFS destroy -r $NAME_VOL
|
|
31 | 32 |
else |
32 | 33 |
exit 1; |
33 | 34 |
fi |
... | ... | |
37 | 38 |
|
38 | 39 |
function interactive { |
39 | 40 |
|
40 |
zfs list
|
|
41 |
$BINZFS list
|
|
41 | 42 |
echo "*** Enter the ZFS Volume Name : ***" |
42 | 43 |
while read inputline |
43 | 44 |
do |
bin/zfs-replica (revision 49) | ||
---|---|---|
6 | 6 |
getConfigSnapshotTool="/sbin/get-conf-snapshot" |
7 | 7 |
zfsSnapshot="/sbin/zfs-snapshot" |
8 | 8 |
FILE_NAME=$1 |
9 |
BINZFS="/sbin/zfs" |
|
10 |
BINZPOOL="/sbin/zpool" |
|
9 | 11 |
|
10 | 12 |
#******************************** |
11 | 13 |
#* function initenv |
... | ... | |
66 | 68 |
} |
67 | 69 |
|
68 | 70 |
function checkCoherence { |
69 |
ssh -o BatchMode=yes root@$server zfs list $namereplica
|
|
71 |
ssh -o BatchMode=yes root@$server $BINZFS list $namereplica
|
|
70 | 72 |
if [ "$?" != "0" ] |
71 | 73 |
then |
72 | 74 |
return false |
... | ... | |
79 | 81 |
if [[ "$server" == "" ]] |
80 | 82 |
then |
81 | 83 |
echo "" |
82 |
CPT_SNAP=$(/sbin/zfs list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@ |wc -l)
|
|
84 |
CPT_SNAP=$($BINZFS list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@ |wc -l)
|
|
83 | 85 |
echo "*** Number of snapshots for $namereplica is : $CPT_SNAP" |
84 |
/sbin/zfs list -t snapshot -r $namereplica
|
|
86 |
$BINZFS list -t snapshot -r $namereplica
|
|
85 | 87 |
|
86 | 88 |
if [ $CPT_SNAP -gt $nbreplica ] |
87 | 89 |
then |
88 | 90 |
echo "*** Detection of the oldest snapshot" |
89 |
for ID_SNAP_OLDER in $(/sbin/zfs list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@)
|
|
91 |
for ID_SNAP_OLDER in $($BINZFS list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@)
|
|
90 | 92 |
do |
91 | 93 |
echo "*** The oldest snapshot is : $ID_SNAP_OLDER" |
92 | 94 |
break |
93 | 95 |
done |
94 |
/sbin/zfs destroy $ID_SNAP_OLDER
|
|
96 |
$BINZFS destroy $ID_SNAP_OLDER
|
|
95 | 97 |
if [ $? -eq 0 ] |
96 | 98 |
then |
97 | 99 |
echo "*** Remove the snapshot $ID_SNAP_OLDER [OK]" |
... | ... | |
102 | 104 |
|
103 | 105 |
else |
104 | 106 |
echo "" |
105 |
CPT_SNAP=$(ssh -o BatchMode=yes root@$server /sbin/zfs list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@ |wc -l)
|
|
107 |
CPT_SNAP=$(ssh -o BatchMode=yes root@$server $BINZFS list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@ |wc -l)
|
|
106 | 108 |
echo "*** Number of snapshots for $namereplica is : $CPT_SNAP" |
107 |
ssh -o BatchMode=yes root@$server /sbin/zfs list -t snapshot -r $namereplica
|
|
109 |
ssh -o BatchMode=yes root@$server $BINZFS list -t snapshot -r $namereplica
|
|
108 | 110 |
|
109 | 111 |
if [ $CPT_SNAP -gt $nbreplica ] |
110 | 112 |
then |
111 | 113 |
echo "*** Detection of the oldest snapshot" |
112 |
for ID_SNAP_OLDER in $(ssh -o BatchMode=yes root@$server /sbin/zfs list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@)
|
|
114 |
for ID_SNAP_OLDER in $(ssh -o BatchMode=yes root@$server $BINZFS list -t snapshot -r $namereplica |cut -d" " -f1 |grep -i $namereplica\@)
|
|
113 | 115 |
do |
114 | 116 |
echo "*** The oldest snapshot is : $ID_SNAP_OLDER" |
115 | 117 |
break |
116 | 118 |
done |
117 |
ssh -o BatchMode=yes root@$server /sbin/zfs destroy $ID_SNAP_OLDER
|
|
119 |
ssh -o BatchMode=yes root@$server $BINZFS destroy $ID_SNAP_OLDER
|
|
118 | 120 |
if [ $? -eq 0 ] |
119 | 121 |
then |
120 | 122 |
echo "*** Remove the snapshot $ID_SNAP_OLDER [OK]" |
... | ... | |
145 | 147 |
if [[ "$server" == "" ]] |
146 | 148 |
then |
147 | 149 |
|
148 |
/sbin/zfs list $parentdataset
|
|
150 |
$BINZFS list $parentdataset
|
|
149 | 151 |
if [[ "?" != "0" ]] |
150 | 152 |
then |
151 |
/sbin/zfs create -p $parentdataset
|
|
153 |
$BINZFS create -p $parentdataset
|
|
152 | 154 |
fi |
153 | 155 |
|
154 |
/sbin/zfs send $snapshot2replicate | /sbin/zfs recv $namereplica
|
|
156 |
$BINZFS send $snapshot2replicate | $BINZFS recv $namereplica
|
|
155 | 157 |
if [[ "$?" == "0" ]] |
156 | 158 |
then |
157 | 159 |
cpt=0 |
... | ... | |
173 | 175 |
checkServerConnection |
174 | 176 |
if [[ "$snapshot2replicate" != "" ]] |
175 | 177 |
then |
176 |
ssh -o BatchMode=yes root@$server /sbin/zfs list $parentdataset
|
|
178 |
ssh -o BatchMode=yes root@$server $BINZFS list $parentdataset
|
|
177 | 179 |
if [[ "?" != "0" ]] |
178 | 180 |
then |
179 |
ssh -o BatchMode=yes root@$server /sbin/zfs create -p $parentdataset
|
|
181 |
ssh -o BatchMode=yes root@$server $BINZFS create -p $parentdataset
|
|
180 | 182 |
fi |
181 | 183 |
|
182 |
/sbin/zfs send $snapshot2replicate |ssh -o BatchMode=yes root@$server /sbin/zfs recv $namereplica
|
|
184 |
$BINZFS send $snapshot2replicate |ssh -o BatchMode=yes root@$server $BINZFS recv $namereplica
|
|
183 | 185 |
if [[ "$?" == "0" ]] |
184 | 186 |
then |
185 | 187 |
cpt=0 |
... | ... | |
208 | 210 |
echo "Start incremental replication" |
209 | 211 |
if [[ "$server" == "" ]] |
210 | 212 |
then |
211 |
cmd="zfs send -i $lastsnapshotReplicated $namevolfs@$lastsnaphot | ssh -o BatchMode=yes root@$server zfs recv $namereplica"
|
|
213 |
cmd="$BINZFS send -i $lastsnapshotReplicated $namevolfs@$lastsnaphot | ssh -o BatchMode=yes root@$server $BINZFS recv $namereplica"
|
|
212 | 214 |
echo $cmd |
213 | 215 |
if [[ "$?" == "0" ]] |
214 | 216 |
then |
... | ... | |
232 | 234 |
then |
233 | 235 |
exit 1 |
234 | 236 |
else |
235 |
/sbin/zfs send -i $lastsnapshotReplicated $namevolfs@$snaphot2replicate | ssh -o BatchMode=yes root@$server /sbin/zfs recv $namereplica
|
|
237 |
$BINZFS send -i $lastsnapshotReplicated $namevolfs@$snaphot2replicate | ssh -o BatchMode=yes root@$server $BINZFS recv $namereplica
|
|
236 | 238 |
if [[ "$?" == "0" ]] |
237 | 239 |
then |
238 | 240 |
cpt=0 |
... | ... | |
264 | 266 |
initenv |
265 | 267 |
|
266 | 268 |
fileconf=$($getConfigSnapshotTool $namevolfs|grep fileconf|cut -d "=" -f2) |
267 |
NBsnapshot=$(/sbin/zfs list -H -r -t snapshot $namevolfs|wc -l)
|
|
269 |
NBsnapshot=$($BINZFS list -H -r -t snapshot $namevolfs|wc -l)
|
|
268 | 270 |
|
269 | 271 |
if [[ $NBsnapshot -eq 0 ]] |
270 | 272 |
then |
... | ... | |
280 | 282 |
while read line |
281 | 283 |
do |
282 | 284 |
snapshot2replicate=$(echo $line |echo $line |sed -e "s/ \+/ /g"|cut -d " " -f1) |
283 |
done <<< "$(/sbin/zfs list -H -r -t snapshot $namevolfs)"
|
|
285 |
done <<< "$($BINZFS list -H -r -t snapshot $namevolfs)"
|
|
284 | 286 |
fullreplication |
285 | 287 |
fi |
286 | 288 |
|
... | ... | |
293 | 295 |
while read line |
294 | 296 |
do |
295 | 297 |
snapshot2replicate=$(echo $line |echo $line |sed -e "s/ \+/ /g"|cut -d " " -f1) |
296 |
done <<< "$(/sbin/zfs list -H -r -t snapshot $namevolfs)"
|
|
298 |
done <<< "$($BINZFS list -H -r -t snapshot $namevolfs)"
|
|
297 | 299 |
fullreplication |
298 | 300 |
fi |
299 | 301 |
|
... | ... | |
312 | 314 |
break |
313 | 315 |
fi |
314 | 316 |
cpt=$cpt+1 |
315 |
done <<< "$(/sbin/zfs list -H -r -t snapshot $namevolfs|tac)"
|
|
317 |
done <<< "$($BINZFS list -H -r -t snapshot $namevolfs|tac)"
|
|
316 | 318 |
lastsnapshot=$(echo $lastsnapshotReplicated |sed -e "s/ \+/ /g"|cut -d " " -f1|cut -d "@" -f2) |
317 | 319 |
|
318 | 320 |
if [ "$snaphot2replicate" == "$lastsnapshot" ] |
... | ... | |
321 | 323 |
exit 1 |
322 | 324 |
|
323 | 325 |
fi |
324 |
check_lastsnapshotReplica=$(ssh -o BatchMode=yes root@$server /sbin/zfs list -H -r -t snapshot $namereplica |grep $lastsnapshot|wc -l)
|
|
325 |
check_currentsnapshotReplica=$(ssh -o BatchMode=yes root@$server /sbin/zfs list -H -r -t snapshot $namereplica |grep $snaphot2replicate=|wc -l)
|
|
326 |
check_lastsnapshotReplica=$(ssh -o BatchMode=yes root@$server $BINZFS list -H -r -t snapshot $namereplica |grep $lastsnapshot|wc -l)
|
|
327 |
check_currentsnapshotReplica=$(ssh -o BatchMode=yes root@$server $BINZFS list -H -r -t snapshot $namereplica |grep $snaphot2replicate=|wc -l)
|
|
326 | 328 |
if [[ $check_lastsnapshotReplica -eq 0 ]] |
327 | 329 |
then |
328 | 330 |
echo "Incoherence, incremental replication failed : $lastsnapshotReplicated is missing" 1>&2 |
bin/disable-replica (revision 49) | ||
---|---|---|
4 | 4 |
DIR_CRON="/etc/cron.d/" |
5 | 5 |
DIR_CONF_REPLICA="/opt/gZFS/replicas/" |
6 | 6 |
BIN_ZFS_REPLICA="/sbin/zfs-replica" |
7 |
BINZFS="/sbin/zfs" |
|
8 |
BINZPOOL="/sbin/zpool" |
|
7 | 9 |
|
8 |
# TODO: traduire les msg |
|
9 | 10 |
|
10 | 11 |
function usage { |
11 | 12 |
echo "Usage :" 1>&2 |
... | ... | |
34 | 35 |
|
35 | 36 |
function interactive { |
36 | 37 |
|
37 |
/sbin/zfs list
|
|
38 |
$BINZFS list
|
|
38 | 39 |
echo "*** Select the ZFS volume/filesystem Name to replicate :" |
39 | 40 |
while read inputline |
40 | 41 |
do |
41 | 42 |
if [ "$inputline" != "" ] |
42 | 43 |
then |
43 |
/sbin/zfs list $inputline
|
|
44 |
$BINZFS list $inputline
|
|
44 | 45 |
if [ $? -eq 0 ] |
45 | 46 |
then |
46 | 47 |
FILE_NAME=$(echo "replica-"${inputline//\//-}) |
bin/enable-snapshot (revision 49) | ||
---|---|---|
4 | 4 |
DIR_CRON="/etc/cron.d/" |
5 | 5 |
DIR_CONF_SNAPSHOT="/opt/gZFS/snapshots/" |
6 | 6 |
BIN_ZFS_SNAPSHOT="/sbin/zfs-snapshot" |
7 |
BINZFS="/sbin/zfs" |
|
8 |
BINZPOOL="/sbin/zpool" |
|
7 | 9 |
|
8 |
# TODO: traduire les msg |
|
9 |
|
|
10 | 10 |
function usage { |
11 | 11 |
echo "Usage : $0 options" 1>&2 |
12 | 12 |
echo "OPTIONS :" 1>&2 |
... | ... | |
38 | 38 |
} |
39 | 39 |
|
40 | 40 |
function interactive { |
41 |
/sbin/zfs list
|
|
41 |
$BINZFS list
|
|
42 | 42 |
echo "*** Select the ZFS volume/filesystem : ***" |
43 | 43 |
|
44 | 44 |
while read inputline |
... | ... | |
63 | 63 |
|
64 | 64 |
if [ "$inputConfirm" = "y" ] |
65 | 65 |
then |
66 |
/sbin/zfs list $NAME_VOL
|
|
66 |
$BINZFS list $NAME_VOL
|
|
67 | 67 |
if [ $? -eq 0 ] |
68 | 68 |
then |
69 | 69 |
echo "*** The ZFS volume/filesystem $NAME_VOL exists ***" |
bin/create-filesystem (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 | 3 |
|
4 |
BINZFS="/sbin/zfs" |
|
5 |
BINZPOOL="/sbin/zpool" |
|
6 |
|
|
4 | 7 |
function usage { |
5 | 8 |
echo "Syntax :" 1>&2 |
6 | 9 |
echo "$0 [options]" 1>&2 |
... | ... | |
15 | 18 |
|
16 | 19 |
function nointeractive { |
17 | 20 |
|
18 |
/sbin/zfs create -o $FS_OPTION $NAME_POOL/$NAME
|
|
21 |
$BINZFS create -o $FS_OPTION $NAME_POOL/$NAME
|
|
19 | 22 |
|
20 | 23 |
} |
21 | 24 |
|
22 | 25 |
|
23 | 26 |
function interactive { |
24 |
/sbin/zfs list
|
|
27 |
$BINZFS list
|
|
25 | 28 |
echo "*** Select the parent zpool : ***" |
26 | 29 |
|
27 | 30 |
while read inputline |
28 | 31 |
do |
29 | 32 |
if [ "$inputline" != "" ] |
30 | 33 |
then |
31 |
/sbin/zfs list |grep -i $inputline
|
|
34 |
$BINZFS list |grep -i $inputline
|
|
32 | 35 |
if [ $? -eq 1 ] |
33 | 36 |
then |
34 | 37 |
echo "*** Select the parent zpool : ***" |
... | ... | |
52 | 55 |
do |
53 | 56 |
if [ "$inputFS" != "" ] |
54 | 57 |
then |
55 |
/sbin/zfs list |grep -i "$inputFS "
|
|
58 |
$BINZFS list |grep -i "$inputFS "
|
|
56 | 59 |
if [ $? -eq 0 ] |
57 | 60 |
then |
58 | 61 |
echo "Filesystem name already exists" |
... | ... | |
65 | 68 |
echo "filesystem name: " |
66 | 69 |
else |
67 | 70 |
NAME_FS=$inputFS |
68 |
/sbin/zfs create $NAME_POOL/$inputFS
|
|
71 |
$BINZFS create $NAME_POOL/$inputFS
|
|
69 | 72 |
if [ $? -eq 0 ] |
70 | 73 |
then |
71 | 74 |
echo "*** ZFS filesystem Creation [OK] ***" |
72 |
/sbin/zfs list
|
|
75 |
$BINZFS list
|
|
73 | 76 |
break |
74 | 77 |
else |
75 | 78 |
echo "/!\\ ZFS filesystem Creation [ERROR] /!\\" |
bin/del-filesystem (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 |
BINZFS="/sbin/zfs" |
|
4 |
BINZPOOL="/sbin/zpool" |
|
3 | 5 |
|
4 | 6 |
function usage { |
5 | 7 |
echo "Description : destroy a ZFS FileSystem." 1>&2 |
... | ... | |
13 | 15 |
|
14 | 16 |
function nointeractive { |
15 | 17 |
|
16 |
MOUNTED=$(zfs get -H mounted $FS_NAME|awk '{ print $3}')
|
|
18 |
MOUNTED=$($BINZFS get -H mounted $FS_NAME|awk '{ print $3}')
|
|
17 | 19 |
|
18 | 20 |
if [ "$MOUNTED" == "no" ] |
19 | 21 |
then |
20 |
is_pool=$(zpool list $FS_NAME)
|
|
22 |
is_pool=$($BINZPOOL list $FS_NAME)
|
|
21 | 23 |
if [ $? == 1 ] |
22 | 24 |
then |
23 |
zfs destroy -r $FS_NAME
|
|
25 |
$BINZFS destroy -r $FS_NAME
|
|
24 | 26 |
else |
25 | 27 |
echo "$FS_NAME is a zpool, cannot remove recursively this filesystem" 1>&2 |
26 | 28 |
exit 1; |
... | ... | |
35 | 37 |
|
36 | 38 |
function interactive { |
37 | 39 |
|
38 |
zfs list
|
|
40 |
$BINZFS list
|
|
39 | 41 |
echo "*** Enter ZFS FileSystem Name: ***" |
40 | 42 |
while read inputline |
41 | 43 |
do |
bin/zpool-get-state (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 | 3 |
|
4 |
BINZFS="/sbin/zfs" |
|
5 |
BINZPOOL="/sbin/zpool" |
|
6 |
|
|
4 | 7 |
function usage { |
5 | 8 |
|
6 | 9 |
echo "Syntax :" |
... | ... | |
8 | 11 |
echo "$0 -h : display this message" |
9 | 12 |
} |
10 | 13 |
function nointeractive { |
11 |
echo $(/sbin/zpool status $poolname|grep -i "state:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")
|
|
12 |
echo $(/sbin/zpool status $poolname|grep -i "scan:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")
|
|
14 |
echo $($BINZPOOL status $poolname|grep -i "state:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")
|
|
15 |
echo $($BINZPOOL status $poolname|grep -i "scan:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")
|
|
13 | 16 |
exit 0 |
14 | 17 |
} |
15 | 18 |
while getopts "in:h" OPTION |
bin/zfs-snapshot (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 |
BINZFS="/sbin/zfs" |
|
4 |
BINZPOOL="/sbin/zpool" |
|
3 | 5 |
|
4 | 6 |
function create_snapshot_volume { |
5 | 7 |
#*** ETAPE DE CREATION DU SNAPSHOT ***# |
... | ... | |
11 | 13 |
|
12 | 14 |
echo "*** Snapshot Creation from $NAME_VOL" |
13 | 15 |
ZDATE=$(date +%Y%m%d%H%M%S) |
14 |
/sbin/zfs snapshot $NAME_VOL@snapshot-$ZDATE
|
|
16 |
$BINZFS snapshot $NAME_VOL@snapshot-$ZDATE
|
|
15 | 17 |
echo "" |
16 | 18 |
#*** FIN ETAPE DE CREATION DU SNAPSHOT ***# |
17 | 19 |
} |
... | ... | |
25 | 27 |
echo "" |
26 | 28 |
echo "*** Snapshot Creation from $NAME_VOL" |
27 | 29 |
ZDATE=$(date +%Y%m%d%H%M%S) |
28 |
/sbin/zfs snapshot $NAME_VOL@snapshot-$ZDATE
|
|
30 |
$BINZFS snapshot $NAME_VOL@snapshot-$ZDATE
|
|
29 | 31 |
echo "" |
30 | 32 |
#*** FIN ETAPE DE CREATION DU SNAPSHOT ***# |
31 | 33 |
} |
... | ... | |
34 | 36 |
function del_old_snapshot { |
35 | 37 |
#*** ETAPE SUPPRESSION DES SNAPSHOTS OBSELETES ***# |
36 | 38 |
echo "" |
37 |
CPT_SNAP=$(/sbin/zfs list -t snapshot -r $NAME_VOL |cut -d" " -f1 |grep -i $NAME_VOL\@ |wc -l)
|
|
39 |
CPT_SNAP=$($BINZFS list -t snapshot -r $NAME_VOL |cut -d" " -f1 |grep -i $NAME_VOL\@ |wc -l)
|
|
38 | 40 |
echo "*** Le nombre de snapshot pour $NAME_VOL est : $CPT_SNAP" |
39 |
/sbin/zfs list -t snapshot -r $NAME_VOL
|
|
41 |
$BINZFS list -t snapshot -r $NAME_VOL
|
|
40 | 42 |
|
41 | 43 |
if [ $CPT_SNAP -gt $NB_SNAP ] |
42 | 44 |
then |
43 | 45 |
echo "*** Detection du snapshot le plus ancien" |
44 |
for ID_SNAP_OLDER in $(/sbin/zfs list -t snapshot -r $NAME_VOL |cut -d" " -f1 |grep -i $NAME_VOL\@)
|
|
46 |
for ID_SNAP_OLDER in $($BINZFS list -t snapshot -r $NAME_VOL |cut -d" " -f1 |grep -i $NAME_VOL\@)
|
|
45 | 47 |
do |
46 | 48 |
echo "*** Le snapshot le plus ancien est : $ID_SNAP_OLDER" |
47 | 49 |
break |
48 | 50 |
done |
49 |
/sbin/zfs destroy $ID_SNAP_OLDER
|
|
51 |
$BINZFS destroy $ID_SNAP_OLDER
|
|
50 | 52 |
if [ $? -eq 0 ] |
51 | 53 |
then |
52 | 54 |
echo "*** Suppression du snapshot $ID_SNAP_OLDER [OK]" |
bin/zfs-clone (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 |
BINZFS="/sbin/zfs" |
|
4 |
BINZPOOL="/sbin/zpool" |
|
3 | 5 |
|
4 | 6 |
function usage { |
5 | 7 |
echo "Syntax :" |
... | ... | |
14 | 16 |
TODAY=$(date +%Y%m%d%H%M%S) |
15 | 17 |
|
16 | 18 |
clone_name=$(echo "$volfs2clone" |sed -e "s/@.*$//g") |
17 |
/sbin/zfs clone $volfs2clone $clone_name-$TODAY-clone
|
|
19 |
$BINZFS clone $volfs2clone $clone_name-$TODAY-clone
|
|
18 | 20 |
if [ "$?" == "0" ] |
19 | 21 |
then |
20 | 22 |
echo "name:$clone_name-$TODAY-clone" |
... | ... | |
24 | 26 |
|
25 | 27 |
function interactive { |
26 | 28 |
|
27 |
/sbin/zfs list -t snapshot
|
|
29 |
$BINZFS list -t snapshot
|
|
28 | 30 |
echo "*** Select Volume or Filesystem to Clone : ***" |
29 | 31 |
while read inputline |
30 | 32 |
do |
... | ... | |
47 | 49 |
fi |
48 | 50 |
if [ "$inputConfirm" != "y" ] |
49 | 51 |
then |
50 |
/sbin/zfs list -t snapshot
|
|
52 |
$BINZFS list -t snapshot
|
|
51 | 53 |
echo "*** Select Volume or Filesystem to Clone : ***" |
52 | 54 |
fi |
53 | 55 |
done |
bin/disable-snapshot (revision 49) | ||
---|---|---|
4 | 4 |
DIR_CRON="/etc/cron.d/" |
5 | 5 |
DIR_CONF_SNAPSHOT="/opt/gZFS/snapshots/" |
6 | 6 |
BIN_ZFS_SNAPSHOT="/sbin/zfs-snapshot" |
7 |
BINZFS="/sbin/zfs" |
|
8 |
BINZPOOL="/sbin/zpool" |
|
7 | 9 |
|
8 |
# TODO: traduire les msg |
|
9 | 10 |
|
10 | 11 |
function usage { |
11 | 12 |
echo "Usage :" 1>&2 |
... | ... | |
34 | 35 |
|
35 | 36 |
function interactive { |
36 | 37 |
|
37 |
/sbin/zfs list
|
|
38 |
$BINZFS list
|
|
38 | 39 |
echo "*** Nom du volume pour desactiver les snapshot :" |
39 | 40 |
while read inputline |
40 | 41 |
do |
41 | 42 |
if [ "$inputline" != "" ] |
42 | 43 |
then |
43 |
/sbin/zfs list $inputline
|
|
44 |
$BINZFS list $inputline
|
|
44 | 45 |
if [ $? -eq 0 ] |
45 | 46 |
then |
46 | 47 |
FILE_NAME=$(echo "snapshot-"${inputline//\//-}) |
bin/get-disk-info (revision 49) | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# $Id$ |
3 | 3 |
|
4 |
BINZFS="/sbin/zfs" |
|
5 |
BINZPOOL="/sbin/zpool" |
|
6 |
|
|
4 | 7 |
SMARTTOOL="/usr/sbin/smartctl" |
5 | 8 |
|
6 | 9 |
function usage { |
... | ... | |
29 | 32 |
echo "DEVBYIDNOPART= $DEVBYIDNOPART" |
30 | 33 |
fi |
31 | 34 |
echo "nameinzpool:$DEVBYIDNOPART" |
32 |
errorread=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
|
|
35 |
errorread=$($BINZPOOL status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
|
|
33 | 36 |
echo "errorread:$errorread" |
34 |
errorwrite=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
|
|
37 |
errorwrite=$($BINZPOOL status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
|
|
35 | 38 |
echo "errorwrite:$errorwrite" |
36 |
errorchecksum=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
|
|
39 |
errorchecksum=$($BINZPOOL status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
|
|
37 | 40 |
echo "errorchecksum:$errorchecksum" |
38 | 41 |
exit 0 |
39 | 42 |
fi |
... | ... | |
53 | 56 |
done<<< "$($SMARTTOOL -i -H /dev/disk/by-id/scsi-$resultMulti)" |
54 | 57 |
DEVBYIDNOPART=$(echo $DEVBYID|cut -d "/" -f4) |
55 | 58 |
echo "nameinzpool:$DEVBYIDNOPART" |
56 |
errorread=$(/sbin/zpool status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
|
|
59 |
errorread=$($BINZPOOL status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
|
|
57 | 60 |
echo "errorread:$errorread" |
58 |
errorwrite=$(/sbin/zpool status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
|
|
61 |
errorwrite=$($BINZPOOL status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
|
|
59 | 62 |
echo "errorwrite:$errorwrite" |
60 |
errorchecksum=$(/sbin/zpool status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
|
|
63 |
errorchecksum=$($BINZPOOL status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
|
|
61 | 64 |
echo "errorchecksum:$errorchecksum" |
62 | 65 |
exit 0 |
63 | 66 |
fi |
Formats disponibles : Unified diff