Re: Amanda and ZFS
2008-04-28 14:13:03
Anthony Worrall wrote:
Hi
unfortunately zfsdump, or "zfs send" as it is now, does not relate to
ufsdump in any way :-(
[...]
I wrote a script to use this but I had a problem getting estimates for
the incremental snapshots.
I have used this script, picked from the list's archive, for about 18
months and I indeed had to make some small changes related to these
estimates.
FWIW, what I use is attached (does the list accept attachements ?)
I can not see how amrecover would not be able to restore from the
snapshot as it does not know the format used. In fact there is no way
that I know of to extract a file from the snapshot sort of recovering
the whole snapshot. This is probably not too much of a big issue as the
tape backup is only needed for disaster recover and snapshot can be used
for file recovery.
amrestore could be used with "zfs receive" to recover the snapshot.
Test restores went fine. Restoring to an incremental level is a little
awkward (one has to rename each restored snaphot before receiving the
next one) but certainly cleaner than doing it from an ufsdump with its
potential resurrected/moved files problems.
#!/bin/pfksh
#need to use pfksh so that zfs can be run
ZFS=/usr/sbin/zfs
#Get the last argument
for FS in $@;
do
echo $FS > /dev/null
done
#Check if the filesystem is zfs or ufs
res=`$ZFS list | /usr/xpg4/bin/egrep "${FS}$"`
if [ $? -eq 0 ]; then
DEV=`echo $res | awk '{ print $1}'`
ESTIMATE=0
LEVEL="unknown"
UPDATE=0
case $1 in
*0*) LEVEL=0;;
*1*) LEVEL=1;;
*2*) LEVEL=2;;
*3*) LEVEL=3;;
*4*) LEVEL=4;;
*5*) LEVEL=5;;
*6*) LEVEL=6;;
*7*) LEVEL=7;;
*8*) LEVEL=8;;
*9*) LEVEL=9;;
*) echo level NOT specfied; exit -1;;
esac
case $1 in
*S*) ESTIMATE=1;;
esac
case $1 in
*u*) UPDATE=1;;
esac
$ZFS list -H -t snapshot | /usr/xpg4/bin/grep -q ${DEV}@0
if [ $? -eq 0 ]; then
$ZFS destroy ${DEV}@0
fi
$ZFS snapshot ${DEV}@0
# make sure all the snapshots up to $LEVEL exist
n=1
while [ $n -le $LEVEL ];
do
$ZFS list -H -t snapshot | /usr/xpg4/bin/grep -q ${DEV}@$n
if [ $? -ne 0 ]; then
LEVEL=$(( $n - 1 ))
break
fi
n=$(($n+1))
done
full=`$ZFS list -H -o refer ${DEV}@0`
#convert returned size into kilobytes
case $full in
*K) full=`echo $full | sed -e 's/K//'`;;
*M) full=`echo $full | sed -e 's/M//'`; full=$(( $full * 1024 ));;
*G) full=`echo $full | sed -e 's/G//'`; full=$(( $full * 1024 * 1024));;
esac
if [ $LEVEL -gt 0 ]; then
incr=`$ZFS list -H -o refer ${DEV}@${LEVEL}`
case $incr in
*K) incr=`echo $incr | sed -e 's/K//'`;;
*M) incr=`echo $incr | sed -e 's/M//'`; incr=$(( $incr * 1024 ));;
*G) incr=`echo $incr | sed -e 's/G//'`; incr=$(( $incr * 1024 * 1024));;
esac
size=$(( $full - $incr ))
# $full can be less than $incr if we recently removed data
# zfs send -i will no be exactly 0, but relatively small
if [ $size -lt 0 ]; then
size=0
fi
else
size=$full
fi
size=$(( $size + 16 ))
if [ $ESTIMATE == 1 ]; then
# echo "doing Estimate $DEV at level $LEVEL" >&2
size=$(( $size * 1024 ))
echo $size
$ZFS destroy ${DEV}@0
else
# echo "Dumping $DEV at level $LEVEL" >&2
if [ $LEVEL -eq 0 ]; then
$ZFS send ${DEV}@0
else
$ZFS send -i ${DEV}@${LEVEL} ${DEV}@0
fi
block=$(( $size * 2 ))
MB=$(( $size / 1024 ))
echo "DUMP: $block blocks (${MB}MB)" >&2
if [ $UPDATE -eq 1 ]; then
for snap in `$ZFS list -H -t snapshot | awk '{print $1}' | egrep
${DEV}@"[1-9]$"`; do
n=`echo $snap | cut -f2 -d@`
if [ $n -gt $LEVEL ]; then
$ZFS destroy $snap
fi
done
n=$(( $LEVEL + 1 ))
$ZFS rename ${DEV}@0 ${DEV}@${n}
else
$ZFS destroy ${DEV}@0
fi
fi
else
/usr/lib/fs/ufs/ufsdump $*
fi
|
|
|