openfiler重裝恢復數據

備份openfiler配置

重裝openfiler。

拷貝下面的腳本到終端執行。

#!/bin/bash
# strip the /mnt lines from fstab as we will be rebuilding them
grep /mnt /etc/fstab -v > _fstab
# create the new volumes.xml file
echo -e "<?xml version=\"1.0\" ?>\n<volumes>" > _volumes.xml
# find all logical volumes and loop
for i in `lvdisplay | grep "LV Name" | sed 's/[^\/]*//'`; do
    fstype=`vol_id $i -t 2> /dev/null`;
    mntpoint=`echo $i | sed 's/\/dev\//\/mnt\//'`/
    vgname=`echo $i | cut -d '/' -f3`
    volid=`echo $i | cut -d '/' -f4`
    args="";
    if [ "$fstype" == "" ]; then
        # assume iscsi since filesystem is unknown
        fstype="iscsi"
        mntpoint=""
    fi
    if [ $fstype == ext3 ] ; then
        args=",acl,user_xattr"
    fi
    if [ $fstype == reiserfs ] ; then
        args=",acl"
    fi
    if [ $fstype == xfs ] ; then
        args=""
    fi
    if [ $fstype != "iscsi" ]; then
        echo "$i $mntpoint $fstype defaults,usrquota,grpquota$args 0 0" >> _fstab
        echo "    <volume id=\"$volid\" name=\"$volid\" mountpoint=\"$mntpoint\" vg=\"$vgname\" fstype=\"$fstype\" />" >> _volumes.xml
        echo "Mounting $mntpoint"
        mkdir -p $mntpoint > /dev/null 2> /dev/null
        umount $mntpoint 2> /dev/null
        mount $mntpoint
    else
        echo "$i - assuming iSCSI"
        echo "    <volume id=\"$volid\" name=\"$volid\" mountpoint=\"\" vg=\"$vgname\" fstype=\"$fstype\" incominguser=\"\" incomingpassword=\"\" outgoinguser=\"\" outgoingpassword=\"\" />" >> _volumes.xml
    fi
done;
echo "</volumes>" >> _volumes.xml
mv -f _fstab /etc/fstab
mv -f _volumes.xml /opt/openfiler/etc/volumes.xml
chown openfiler.openfiler /opt/openfiler/etc/volumes.xml

還原openfiler配置。

如果是iscsi,需要刪除Volume Group後再還原配置。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章