######################################## #####################
# USB BACKUP Utility for ENIGMA2
# Version 1.0 - 03-12.2010
# supports USB Backups
######################################## #####################[/B]
Code:
#
#############################################################
# USB BACKUP Utility for ENIGMA2
# Version 1.0 - 03-12.2010
# supports USB Backups
#############################################################
#
#!/bin/sh
VERSION="Version 1.0 - 03.12.2010"
DIRECTORY=$1
if grep et9000 /etc/hostname > /dev/null ; then
MODEL=et9000
OPTIONS="--eraseblock=0x20000 -n -l"
else
echo "No right MODEL Box detected !!!"
exit 0
fi
echo "________________________________________________________"
echo " "
echo "USB Backup Tool for $MODEL " $VERSION
echo "________________________________________________________"
echo " "
echo "Please be patience, a backup will now be made,"
echo "this will take approximately 2 minutes "
echo "________________________________________________________"
DATE=`date +%Y%m%d_%H%M%S`
IMAGEVERSION=`date +%Y%m%d`
MKFS=/usr/bin/mkfs.jffs2
BUILDIMAGE=/usr/bin/buildimage
NANDDUMP=/usr/bin/nanddump
EXTRA=$DIRECTORY/fullbackup_$MODEL/$DATE
if [ ! -f $MKFS ] ; then
echo $MKFS" not found"
exit 0
fi
if [ ! -f $BUILDIMAGE ] ; then
echo $BUILDIMAGE" not found"
exit 0
fi
if [ ! -f $NANDDUMP ] ; then
echo $NANDDUMP" not found"
exit 0
fi
rm -rf $DIRECTORY/bi
mkdir -p $DIRECTORY/bi
mkdir -p /tmp/bi/boot
mkdir -p /tmp/bi/root
if [ $MODEL = "et9000" ] ; then
mount -t jffs2 /dev/mtdblock2 /tmp/bi/boot
mount -t jffs2 /dev/mtdblock3 /tmp/bi/root
fi
if [ -s $BUILDIMAGE ] ; then
echo "Create boot.jffs2"
$MKFS --root=/tmp/bi/boot --faketime --output=$DIRECTORY/bi/boot.jffs2 $OPTIONS
echo "Create root.jffs2"
$MKFS --root=/tmp/bi/root --faketime --output=$DIRECTORY/bi/root.jffs2 $OPTIONS
fi
echo "Create kerneldump"
if [ $MODEL = "et9000" ] ; then
nanddump /dev/mtd1 -o -b > $DIRECTORY/bi/vmlinux.gz
fi
echo "________________________________________________________"
echo " "
echo "Creating $MODEL USB-Backup Image"
echo "________________________________________________________"
mkdir -p $DIRECTORY/$MODEL
mkdir -p $EXTRA
mv $DIRECTORY/bi/root.jffs2 $DIRECTORY/$MODEL/rootfs.bin
mv $DIRECTORY/bi/boot.jffs2 $DIRECTORY/$MODEL/boot.bin
mv $DIRECTORY/bi/vmlinux.gz $DIRECTORY/$MODEL/kernel.bin
echo "rename this file to 'force' to force an update without confirmation" > $DIRECTORY/$MODEL/noforce;
echo $MODEL-$IMAGEVERSION > $DIRECTORY/$MODEL/imageversion;
cp -r $DIRECTORY/$MODEL $EXTRA/$MODEL #copy the made back-up to images
if [ -f $DIRECTORY/$MODEL/rootfs.bin -a -f $DIRECTORY/$MODEL/boot.bin -a -f $DIRECTORY/$MODEL/kernel.bin -a -f $DIRECTORY/$MODEL/imageversion -a -f $DIRECTORY/$MODEL/noforce ] ; then
echo "________________________________________________________"
echo " "
echo "USB Image created on:" $DIRECTORY"/$MODEL "
echo "and there is made an extra copy on:"
echo $EXTRA"/$MODEL"
echo "________________________________________________________"
echo " "
echo " To restore the image: "
echo "Place the USB-stick in the front USB-port and switch the "
echo "$MODEL off and on with the powerswitch on the back of "
echo "the $MODEL. Follow the instructions on front-display."
echo " "
else
echo "Image creation failed - "
echo "e.g. wrong backup destination or"
echo "no space left on backup device"
fi
umount /tmp/bi/root
umount /tmp/bi/boot
rm -rf /tmp/bi
rm -rf $DIRECTORY/bi
exit