Clone only local proporties for new BE, set them at creation not later which improves speed.

This commit is contained in:
Slawomir Wojciech Wojtczak (vermaden) 2012-05-04 00:42:50 +02:00
parent 521acbc5c1
commit 5c3eaa7170
1 changed files with 12 additions and 23 deletions

33
beadm
View File

@ -68,26 +68,21 @@ __be_new() { # 1=SOURCE 2=TARGET
echo "ERROR: Cannot create snapshot '${1}@${2##*/}'" echo "ERROR: Cannot create snapshot '${1}@${2##*/}'"
exit 1 exit 1
} }
zfs clone ${1}@${2##*/} ${2}
} }
zfs list -H -o name -t filesystem -r ${1} \ zfs list -H -o name -t filesystem -r ${1} \
| grep -v -E "${1}$" \ | while read FS
| while read I
do do
DATASET=$( echo ${I} | sed s/"${POOL}\/ROOT\/${1##*/}\/"//g ) OPTS=""
zfs clone ${I}@${2##*/} ${2}/${DATASET} while read NAME PROPERTY VALUE SOURCE
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
do 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##*/} SOURCE=${1##*/}
TARGET=${2##*/} TARGET=${2##*/}
DATASET=$( echo ${I} | awk '{print $1}' | sed s/"${POOL}\/ROOT\/${SOURCE}"/"${POOL}\/ROOT\/${TARGET}"/g ) DATASET=$( echo ${FS} | awk '{print $1}' | sed -E s/"^${POOL}\/ROOT\/${SOURCE}"/"${POOL}\/ROOT\/${TARGET}"/g )
PROPERTY=$( echo ${I} | awk '{print $2}' ) zfs clone -o canmount=noauto ${OPTS} ${FS}@${2##*/} ${DATASET}
VALUE=$( echo ${I} | awk '{print $3}' )
zfs set ${PROPERTY}=${VALUE} ${DATASET}
done done
echo "Created successfully" echo "Created successfully"
} }
@ -184,7 +179,6 @@ case ${1} in
zfs list -H -o name -t filesystem -r ${POOL}/ROOT/${2} \ zfs list -H -o name -t filesystem -r ${POOL}/ROOT/${2} \
| while read I | while read I
do do
MOUNT=$( echo ${I} | sed s/"${POOL}\/ROOT\/${2}"//g )
zfs set canmount=on ${I} 2> /dev/null zfs set canmount=on ${I} 2> /dev/null
zfs promote ${I} 2> /dev/null zfs promote ${I} 2> /dev/null
done done
@ -202,11 +196,6 @@ case ${1} in
case ${CHOICE} in case ${CHOICE} in
(Y|y|[Yy][Ee][Ss]) (Y|y|[Yy][Ee][Ss])
__be_snapshot ${POOL}/ROOT/${2} && { __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 || { zfs destroy ${POOL}/ROOT/${2} 1> /dev/null 2> /dev/null || {
echo "ERROR: Snapshot '${2}' is origin for other boot environment(s)" echo "ERROR: Snapshot '${2}' is origin for other boot environment(s)"
exit 1 exit 1
@ -221,13 +210,13 @@ case ${1} in
do do
zfs promote ${I} 2> /dev/null zfs promote ${I} 2> /dev/null
done done
}
echo "${ORIGINS}" \ echo "${ORIGINS}" \
| while read I | while read I
do do
zfs destroy -r ${I} 2> /dev/null zfs destroy -r ${I} 2> /dev/null
done done
}
} }
echo "Destroyed successfully" echo "Destroyed successfully"
;; ;;