Permalink
Browse files

Clone only local proporties for new BE, set them at creation not late…

…r which improves speed.
  • Loading branch information...
1 parent 521acbc commit 6cbdf50c173c2e5a1dcaf27230b45fac9f028968 @vermaden vermaden committed May 3, 2012
Showing with 12 additions and 23 deletions.
  1. +12 −23 beadm
View
35 beadm
@@ -68,26 +68,21 @@ __be_new() { # 1=SOURCE 2=TARGET
echo "ERROR: Cannot create snapshot '${1}@${2##*/}'"
exit 1
}
- zfs clone ${1}@${2##*/} ${2}
}
zfs list -H -o name -t filesystem -r ${1} \
- | grep -v -E "${1}$" \
- | while read I
- do
- DATASET=$( echo ${I} | sed s/"${POOL}\/ROOT\/${1##*/}\/"//g )
- zfs clone ${I}@${2##*/} ${2}/${DATASET}
- zfs set canmount=noauto ${2}/${DATASET}
- done
- zfs get -r -H quota,reservation,recordsize,mountpoint,sharenfs,checksum,atime,compression,exec,setuid,readonly,jailed,snapdir,aclmode,aclinherit,copies,sharesmb,primarycache,secondarycache,dedup,logbias,sync ${1} \
- | grep -v "@" \
- | while read I
+ | while read FS
do
+ OPTS=""
+ while read NAME PROPERTY VALUE SOURCE
+ do
+ OPTS="-o ${PROPERTY}=${VALUE} ${OPTS}"
+ done << EOF
+$( zfs get -s local,none -H all ${FS} | grep -v -E "(type|creation|used|available|referenced|compressratio|mounted|origin|version|utf8only|normalization|casesensitivity|vscan|nbmand|mlslabel|refcompressratio|canmount)" )
+EOF
SOURCE=${1##*/}
TARGET=${2##*/}
- DATASET=$( echo ${I} | awk '{print $1}' | sed s/"${POOL}\/ROOT\/${SOURCE}"/"${POOL}\/ROOT\/${TARGET}"/g )
- PROPERTY=$( echo ${I} | awk '{print $2}' )
- VALUE=$( echo ${I} | awk '{print $3}' )
- zfs set ${PROPERTY}=${VALUE} ${DATASET}
+ DATASET=$( echo ${FS} | awk '{print $1}' | sed -E s/"^${POOL}\/ROOT\/${SOURCE}"/"${POOL}\/ROOT\/${TARGET}"/g )
+ zfs clone -o canmount=noauto ${OPTS} ${FS}@${2##*/} ${DATASET}
done
echo "Created successfully"
}
@@ -184,7 +179,6 @@ case ${1} in
zfs list -H -o name -t filesystem -r ${POOL}/ROOT/${2} \
| while read I
do
- MOUNT=$( echo ${I} | sed s/"${POOL}\/ROOT\/${2}"//g )
zfs set canmount=on ${I} 2> /dev/null
zfs promote ${I} 2> /dev/null
done
@@ -202,11 +196,6 @@ case ${1} in
case ${CHOICE} in
(Y|y|[Yy][Ee][Ss])
__be_snapshot ${POOL}/ROOT/${2} && {
- zfs list -H -o origin -r ${POOL}/ROOT/${2} \
- | while read I
- do
- zfs destroy ${I}
- done
zfs destroy ${POOL}/ROOT/${2} 1> /dev/null 2> /dev/null || {
echo "ERROR: Snapshot '${2}' is origin for other boot environment(s)"
exit 1
@@ -221,13 +210,13 @@ case ${1} in
do
zfs promote ${I} 2> /dev/null
done
-
+ }
echo "${ORIGINS}" \
| while read I
do
zfs destroy -r ${I} 2> /dev/null
done
- }
+
}
echo "Destroyed successfully"
;;

0 comments on commit 6cbdf50

Please sign in to comment.