Linux之使用extundelete恢复删除文件

Linux之使用extundelete恢复删除文件

1.背景

手动误删除某目录或文件,没有备份,现在需要使用extundelete来恢复已经删除的文件。

2.部署

2.1 epel仓库安装
yum install extundelete -y

2.2 源码编译安装
wget  http://zy-res.oss-cn-hangzhou.aliyuncs.com/server/extundelete-0.2.4.tar.bz2
yum -y install  bzip2  e2fsprogs-devel  e2fsprogs  gcc-c++ make
tar -xvjf extundelete-0.2.4.tar.bz2
cd extundelete-0.2.4 ./configure
make && make install

3.umount该文件所在磁盘,或者以read only方式重新挂载

为了避免分区已删除文件的数据存储位置被覆写后无法继续恢复,因此我们的第一个动作就是要将恢复数据的分区卸载或重新只读挂载。

3.1 首先需要umount该文件所在磁盘,或者以read only方式重新挂载
umount  /data
或者
mount -o remount,ro /data  
注意:个人建议第二种方式只读挂载。

4.恢复前操作

删除前
[root@docker1 data]# ll
总用量 5120800
-rwxr-xr-x. 1 root root        477 10月 25 10:07 bzip2.sh
drwxr-xr-x. 2 root root       4096 10月 25 10:07 docker
drwxr-xr-x. 5 root root       4096 10月 25 10:07 elasticsearch
-rwxr-xr-x. 1 root root        473 10月 25 10:06 gzip.sh
drwx------. 2 root root      16384 10月 24 21:29 lost+found
-rwxr-xr-x. 1 root root        461 10月 25 10:06 lz4.sh
-rwxr-xr-x. 1 root root        458 10月 25 10:06 lzop.sh
-rw-r--r--. 1 root root 5242880000 10月 25 10:08 test5
-rw-r--r--. 1 root root     762784 10月 25 10:08 test5.tar.xz
-rw-r--r--. 1 root root        260 10月 25 10:08 time.txt
-rwxr-xr-x. 1 root root        472 10月 25 10:08 xz.sh

删除
rm -f test5.tar.xz

查看删除文件或目录的名称
[root@docker1 data]# extundelete /dev/sdb1 --inode 2  (根分区inode值为2)
File name                                       | Inode number | Deleted status
.                                                 2
..                                                2
lost+found                                        11
bzip2.sh                                          12
gzip.sh                                           13
lz4.sh                                            14
lzop.sh                                           15
test5                                             16
docker                                            131073
elasticsearch                                     524289
test5.tar.xz                                      17             Deleted
time.txt                                          18
xz.sh                                             19

4.extundelete恢复单个文件

[root@docker1 data]# extundelete /dev/sdb1 --restore=file  test5.tar.xz

5.extundelete恢复单个目录

[root@docker1 data]# extundelete /dev/sdb1 --restore-dirctory  /data/redis

6.extundelete恢复所有文件

[root@docker1 data]# extundelete /dev/sdb1 --restore-all
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东城绝神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值