README src
[root@localhost extundelete-0.2.4]# ./configure
Configuring extundelete 0.2.4
Writing generated files to disk
[root@localhost extundelete-0.2.4]# make
make -s all-recursive
Making all in src
extundelete.cc:571: 警告:未使用的参数‘flags’
[root@localhost extundelete-0.2.4]# make install
Making install in src
/usr/bin/install -c extundelete '/usr/local/bin'
5.准备好用于测试的分区,/dev/sdb1
为ext4
格式,挂载到/mnt/ext4
目录下。
[root@localhost ~]# mkdir /mnt/ext4
[root@localhost ~]# mount /dev/sdb1 /mnt/ext4/
[root@localhost ~]# df -hT /mnt/ext4/
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 ext4 20G 172M 19G 1% /mnt/ext4
6.创建测试文件。
[root@localhost ~]# cd /mnt/ext4/
[root@localhost ext4]# echo 1 > a
[root@localhost ext4]# echo 2 > b
[root@localhost ext4]# echo 3 > c
[root@localhost ext4]# ls
a b c lost+found
7.删除测试文件。
[root@localhost ext4]# rm -f a b
[root@localhost ext4]# ls
c lost+found
8.卸载对应的分区。
[root@localhost ext4]# cd
[root@localhost ~]# umount /mnt/ext4/
9.恢复删除的内容。
[root@localhost ~]# extundelete /dev/sdb1 --restore-all
NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... 160 groups loaded.
Loading journal descriptors ... 24 descriptors loaded.
Searching for recoverable inodes in directory / ...
2 recoverable inodes found.
Looking through the directory structure for deleted files ...
0 recoverable inodes still lost.
10.恢复的文件会在在当前目录下的RECOVERED_FILES
文件夹内。
[root@localhost ~]# ls RECOVERED_FILES/
a b
XFS 类型文件备份和恢复
extundelete
工具仅可以恢复EXT
类型的文件,无法恢复CentOS 7
系统默认采用xfs
类型的文件。针对xfs
文件系统目前也没有比较成熟的文件恢复工具,所以建议提前做好数据备份,以避免数据丢失。
xfs
类型的文件可使用xfsdump
与xfsrestore
工具进行备份恢复。若系统中未安装xfsdump
与xfsrestore
工具,可以通过yum install -y xfsdump
命令安装。xfsdump
按照inode
顺序备份一个xfs
文件系统。
xfsdump
的备份级别有两种:0
表示完全备份;1-9
表示增量备份。默认为0
。
xfsdump -f 备份存放位置 要备份路径或设备文件
-f
:指定备份文件目录
-L
:指定标签session label
-M
:指定设备标签media label
-s
:备份单个文件,-s
后面不能直接跟路径。
1.xfsdump
不支持没有挂载的文件系统备份,所以只能备份已挂载的;
2.xfsdump
必须使用root
的权限才能操作(涉及文件系统的关系);
3.xfsdump
只能备份XFS
文件系统;
4.xfsdump
备份下来的数据(档案或储存媒体)只能让xfsrestore
解析;
5.xfsdump
是透过文件系统的UUID
来分辨各个备份档的,因此不能备份两个具有相同UUID
的文件系统。
xfsrestore -f 恢复文件的位置 存放恢复后文件的路径
Demo
1.准备好用于测试的分区,/dev/sdb1
为ext4
格式,挂载到/mnt/ext4
目录下。
[root@localhost ~]# mkdir /mnt/xfs
[root@localhost ~]# mount /dev/sdb1 /mnt/xfs/
[root@localhost ~]# df -hT /mnt/xfs/
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 xfs 20G 33M 20G 1% /mnt/xfs
2.创建测试文件。
[root@localhost ~]# cd /mnt/xfs/
[root@localhost xfs]# mkdir test
[root@localhost xfs]# touch a.txt
[root@localhost xfs]# touch test/b.txt
3.可以使用tree
查看目录结构。
[root@localhost ~]# yum install tree -y
[root@localhost ~]# tree /mnt/xfs/
/mnt/xfs/
├── a.txt
└── test
└── b.txt
1 directory, 2 files
4.使用xfsdump
命令备份整个分区。
[root@localhost ~]# xfsdump -f /opt/dump_sdb1 /dev/sdb1
xfsdump: using file dump (drive_simple) strategy
xfsdump: version 3.1.4 (dump format 3.0) - type ^C for status and control
============================= dump label dialog ==============================
please enter label for this dump session (timeout in 300 sec)
-> dump_sdb1 //指定备份会话标签
session label entered: "dump_sdb1"
--------------------------------- end dialog ---------------------------------
xfsdump: level 0 dump of localhost.localdomain:/mnt/xfs
xfsdump: dump date: Fri Sep 6 13:36:12 2019
xfsdump: session id: 7