香港服務(wù)器centos系統(tǒng)恢復(fù)誤刪除的文件
CentOS系統(tǒng)中,當(dāng)誤刪除了文件后,進行以下幾步操來恢復(fù)文件。
1、關(guān)掉所有的服務(wù)
當(dāng)發(fā)現(xiàn)誤刪除文件時,為了盡可能的恢復(fù)數(shù)據(jù),先要關(guān)掉所有的正在進行的服務(wù),不要再進行數(shù)據(jù)的寫入,要不然恢復(fù)的概率那就低了。我們可以直接
# killall 進程名
或者
# kill -9 pid
然后把誤刪除的文件所在分區(qū),重新掛載成只讀的
# mount -o ro /dev/sdb /data/
# yum install -y e2fsprogs* //安裝依賴包
# wget http://www.xiayu04.cn/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2
# tar -jxvf extundelete-0.2.4.tar.bz2
# cd extundelete-0.2.4
# ./configure –prefix=/usr/local/extundelete # make && make install
3、驗證是否安裝成功
# cd /usr/local/extundelete/bin # ./extundelete -v
4、恢復(fù)數(shù)據(jù)
實例:假如我們誤刪除文件為 test.txt,所在分區(qū)為/dev/sdb。 1)掃描文件 # /usr/local/extundelete/bin/extundelete /dev/sdb –inode 2 //掃描哪些文件被刪除了 2)恢復(fù)文件
# /usr/local/extundelete/bin/extundelete –restore-file test.txt /dev/sdb
3)查看文件 恢復(fù)的文件在當(dāng)前目錄下的 RECOVERED_FILES/ ?錄下 # ls ./RECOVERED_FILES/
可以看到 test.txt 文件。
注意:
如果想恢復(fù)整個分區(qū)上的文件,則可以執(zhí)行以下命令 # /usr/local/extundelete/bin/extundelete –restore-all /dev/sdb 恢復(fù)后的文件也在 ./RECOVERED_FILES/ 目錄下
5、后續(xù)工作
1)重新掛載該分區(qū)為可寫。 2)備份重要數(shù)據(jù)。 3)覆蓋我們恢復(fù)出來的數(shù)據(jù)。 4)重啟服務(wù)器,恢復(fù)之前關(guān)閉的各種服務(wù)。