首先运行安装恢复用的apk的install.sh脚本!!!
clear
echo -e "\033[31m 下载xfs恢复用的apk \033[0m"
#首次运行请将备注标识:<<EOF删除!
:<<EOF
yum install -y make cmake gcc gcc-c++ pcre pcre-devel zip unzip
wget https://core.tcl-lang.org/tcl/zip/0074847583/tcl-0074847583.zip --no-check-certificate
unzip tcl-0074847583.zip
cd tcl-0074847583/unix/
./configure
make && make install
ln -s /usr/local/bin/tclsh8.7 /usr/bin/tclsh
sleep 3
wget https://core.tcl-lang.org/tcllib/uv/tcllib-1.21.tar.gz --no-check-certificate
tar zxvf tcllib-1.21.tar.gz
cd tcllib-1.21
./installer.tcl
sleep 3
wget https://github.com/ianka/xfs_undelete/archive/refs/tags/v11.0.zip --no-check-certificate
unzip v11.0.zip
cd xfs_undelete-11.0/
ll
mkdir -p package
find ./ -name tcl-0074847583.zip -o -name tcllib-1.21.tar.gz -o -name v11.0.zip -type f|xargs -i cp {} ./package
EOF
#首次运行请将备注标识EOF删除!
echo -e "\033[35m 创建环境变量\033[0m"
opath=$(pwd)$(find ./ -path *xfs_undelete-11.0|awk '{a=substr($0, 2, length($0)-1);print a"/"}')
sed -i "/xfs_undelete/d" /etc/profile
echo export xfs_undelete=$opath |tee -a /etc/profile
chmod 777 $opath
source /etc/profile
,现在模拟删除
现在执行sh recovery.sh
clear
mkdir -p ./recovery
echo -e "\033[31m 请选择删除文件所在的磁盘 \033[0m"
df -Th|grep -E "xfs"|awk '{print NR":"$1}'
read -p "" n
disk=`df -Th|grep -E "xfs"|awk 'NR=="'${n}'"{print $1}'`
echo $disk
$xfs_undelete/xfs_undelete -t -24hour -o ./recovery $disk
#mount -o ro /dev/sdb1 /mnt
sudo mount -o remount,rw /dev/sdb1 /data
选择删除数据所在的硬盘
OK,发现数据都恢复了,但是名称变了,所以务必想起原文件名称!