에서 Linux
삭제 rm
명령 중요한 파일을 삭제하려면 다음, 너무 긴장하지 말고 제대로 작동하거나 복원 할 수 있습니다 선도, 오용 때문일 수 있습니다 때로는 조심해야합니다.
파일 복구 #의 EXT 유형
파일을 삭제하면 실제로 제거되지 않습니다 inode
노드와 block
데이터를하지만, 내부의 파일의 상위 디렉토리에 block
이 파일의 이름을 삭제합니다. Linux
에 의해 Link
더이없는 경우 삭제 된 파일의 수를 제어하는 파일은 Link
시간이 파일은 삭제됩니다.
물론, 통과되지 않았 음을, 여기 완전히 제거 언급 回收站
등의 사용으로, 케이스 뒷면을 rm -rf
데이터를 삭제합니다. 내용은 Linux
아래의 EXT
파일 시스템, 사용 가능한 복구 도구 debugfs
, ext3grep
, extundelete
등등합니다. 어떤 extundelete
오픈 소스 Linux
데이터 복구 도구, 지원 ext3
, ext4
파일 시스템.
데이터가 실수로 삭제 한 데이터가 루트 파티션에 오류가 제거 된 경우, 할 수있는 처음의 데이터가 삭제 된 파티션을 제거하는 것입니다, 당신은 시스템을 단일 사용자 모드를 입력해야하고, 읽기 전용 모드에서 루트 파티션 마운트. 파일을 삭제 한 후, 파일 만 있기 때문에 그 이유는 매우 간단 inode
디스크가 읽기 - 쓰기 모드로 마운트 계속되면 포인터 노드가 삭제됩니다 부문, 실제 파일도 디스크에 저장되어, 이러한 삭제 된 파일 운영 시스템 데이터 블록은 그 후 데이터베이스는 정말, 복구 도구는 양보 손실 새로운 데이터로 덮어 밖으로 다시 할당 할 수 있습니다. 그래서 읽기 전용으로 마운트 모드 디스크는 성공적인 데이터 복구의 비율을 증가시키기 위해, 덮어 쓰기 데이터베이스의 데이터의 위험을 최소화 할 수 있습니다.
데모#
설치를 컴파일에서 extundelete
두 종속성을 설치해야합니다 전에 e2fsprogs-libs
및 e2fsprogs-devel
시스템에서, 두 개의 패키지 설치 디스크를 /Package
,이 디렉토리를 사용 rpm
하거나 yum
명령을 설치합니다. e2fsprogs-devel
설치에 따라 libcom_err-devel
패키지.
1. 시스템이 사용되어 rhel6.5
본원되어 디스크 설치 의존성를 탑재, rpm
실장.
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/cdrom/Packages/
[root@localhost Packages]# rpm -ivh e2fsprogs-libs-1.41.12-18.el6.x86_64.rpm
warning: e2fsprogs-libs-1.41.12-18.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
package e2fsprogs-libs-1.41.12-18.el6.x86_64 is already installed
[root@localhost Packages]# rpm -ivh libcom_err-devel-1.41.12-18.el6.x86_64.rpm
warning: libcom_err-devel-1.41.12-18.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:libcom_err-devel ########################################### [100%]
[root@localhost Packages]# rpm -ivh e2fsprogs-devel-1.41.12-18.el6.x86_64.rpm
warning: e2fsprogs-devel-1.41.12-18.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:e2fsprogs-devel ########################################### [100%]
2. 지역 만들기 yum
, 소스를 빌드 환경을 설치합니다.
[root@localhost ~]# yum install gcc gcc-c++ -y
3. 추출 extundelete
패키지를.
[root@localhost ~]# tar jxvf extundelete-0.2.4.tar.bz2 -C ~
extundelete-0.2.4/
extundelete-0.2.4/acinclude.m4
extundelete-0.2.4/missing
extundelete-0.2.4/autogen.sh
extundelete-0.2.4/aclocal.m4
extundelete-0.2.4/configure
extundelete-0.2.4/LICENSE
extundelete-0.2.4/README
extundelete-0.2.4/install-sh
extundelete-0.2.4/config.h.in
extundelete-0.2.4/src/
extundelete-0.2.4/src/extundelete.cc
extundelete-0.2.4/src/block.h
extundelete-0.2.4/src/kernel-jbd.h
extundelete-0.2.4/src/insertionops.cc
extundelete-0.2.4/src/block.c
extundelete-0.2.4/src/cli.cc
extundelete-0.2.4/src/extundelete-priv.h
extundelete-0.2.4/src/extundelete.h
extundelete-0.2.4/src/jfs_compat.h
extundelete-0.2.4/src/Makefile.in
extundelete-0.2.4/src/Makefile.am
extundelete-0.2.4/configure.ac
extundelete-0.2.4/depcomp
extundelete-0.2.4/Makefile.in
extundelete-0.2.4/Makefile.am
4. 구성, 컴파일하고 설치 extundelete
패키지를
[root@localhost ~]# cd extundelete-0.2.4
[root@localhost extundelete-0.2.4]# ls
acinclude.m4 aclocal.m4 autogen.sh config.h.in configure configure.ac depcomp install-sh LICENSE Makefile.am Makefile.in missing 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
파티션을 대응하는 제 하역.
[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 유형
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
경로와 직접적 뒤에.
- 를 사용하여
xfsdump
, 다음과 같은 몇 가지 제한 사항에주의해야합니다
1. xfsdump
그렇게 만 백업, 마운트 된 파일 시스템 백업을 지원하지 않습니다 장착,
2. xfsdump
당신은 사용해야합니다 root
(관계가 파일 시스템을 포함) 운영 권한을, 그리고
3 xfsdump
만 백업 할 XFS
파일 시스템,
4. xfsdump
아래로 백업 데이터 (파일 또는 저장 매체)를 전용 할 수 xfsrestore
파싱;
5 xfsdump
파일 시스템 통해 UUID
백업 파일의 각각을 구별하기 위해, 두 개의 백업 동일한 가질 수 UUID
파일 시스템.
xfsrestore -f 恢复文件的位置 存放恢复后文件的路径
데모#
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: 74232f85-124c-4486-8d91-f35208534f74
xfsdump: session label: "dump_sdb1"
xfsdump: ino map phase 1: constructing initial dump list
xfsdump: ino map phase 2: skipping (no pruning necessary)
xfsdump: ino map phase 3: skipping (only one dump stream)
xfsdump: ino map construction complete
xfsdump: estimated dump size: 21760 bytes
xfsdump: /var/lib/xfsdump/inventory created
============================= media label dialog =============================
please enter label for media in drive 0 (timeout in 300 sec)
-> sdb1 //指定设备标签,就是对要备份的设备做一个描述
media label entered: "sdb1"
--------------------------------- end dialog ---------------------------------
xfsdump: creating dump session media file 0 (media 0, file 0)
xfsdump: dumping ino map
xfsdump: dumping directories
xfsdump: dumping non-directory files
xfsdump: ending media file
xfsdump: media file size 22952 bytes
xfsdump: dump size (non-dir files) : 0 bytes
xfsdump: dump complete: 46 seconds elapsed
xfsdump: Dump Summary:
xfsdump: stream 0 /opt/dump_sdb1 OK (success)
xfsdump: Dump Status: SUCCESS
5. 백업 정보와 내용을 검토합니다.
[root@localhost ~]# xfsdump -I
file system 0:
fs id: f8805a3e-089e-4875-ad54-d31e5dc98835
session 0:
mount point: localhost.localdomain:/mnt/xfs
device: localhost.localdomain:/dev/sdb1
time: Fri Sep 6 13:36:12 2019
session label: "dump_sdb1"
session id: 74232f85-124c-4486-8d91-f35208534f74
level: 0
resumed: NO
subtree: NO
streams: 1
stream 0:
pathname: /opt/dump_sdb1
start: ino 68 offset 0
end: ino 70 offset 0
interrupted: NO
media files: 1
media file 0:
mfile index: 0
mfile type: data
mfile size: 22952
mfile start: ino 68 offset 0
mfile end: ino 70 offset 0
media label: "sdb1"
media id: cc32446f-42e8-489b-867f-84a55949c1fa
xfsdump: Dump Status: SUCCESS
6. 삭제 테스트 파일은 시뮬레이션 데이터 손실을 만들었습니다.
[root@localhost ~]# rm -rf /mnt/xfs/*
[root@localhost ~]# tree /mnt/xfs/
/mnt/xfs/
0 directories, 0 files
7. 파일을 파일을 손실 복구 할 수 있습니다.
[root@localhost ~]# xfsrestore -f /opt/dump_sdb1 /mnt/xfs/
xfsrestore: using file dump (drive_simple) strategy
xfsrestore: version 3.1.4 (dump format 3.0) - type ^C for status and control
xfsrestore: searching media for dump
xfsrestore: examining media file 0
xfsrestore: dump description:
xfsrestore: hostname: localhost.localdomain
xfsrestore: mount point: /mnt/xfs
xfsrestore: volume: /dev/sdb1
xfsrestore: session time: Fri Sep 6 13:36:12 2019
xfsrestore: level: 0
xfsrestore: session label: "dump_sdb1"
xfsrestore: media label: "sdb1"
xfsrestore: file system id: f8805a3e-089e-4875-ad54-d31e5dc98835
xfsrestore: session id: 74232f85-124c-4486-8d91-f35208534f74
xfsrestore: media id: cc32446f-42e8-489b-867f-84a55949c1fa
xfsrestore: using online session inventory
xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: 2 directories and 3 entries processed
xfsrestore: directory post-processing
xfsrestore: restoring non-directory files
xfsrestore: restore complete: 0 seconds elapsed
xfsrestore: Restore Summary:
xfsrestore: stream 0 /opt/dump_sdb1 OK (success)
xfsrestore: Restore Status: SUCCESS
[root@localhost ~]# tree /mnt/xfs/
/mnt/xfs/
├── a.txt
└── test
└── b.txt
1 directory, 2 files