CentOS系統復原誤刪除的檔案

來源:互聯網
上載者:User

標籤:centos   linux   誤刪除   

 

CentOS系統中,當誤刪除了檔案後,進行以下幾步操來恢複檔案。

 

1、關掉所有的服務

當發現誤刪除檔案時,為了儘可能的恢複資料,先要關掉所有的進行中的服務,不要再進行資料的寫入,要不然恢複的機率那就低了。我們可以直接

# killall 進程名

或者

# kill -9 pid

然後把誤刪除的檔案所在分區,重新掛載成唯讀

# mount -o ro /dev/sdb  /data/ 

 

2、安裝extundelete工具

# yum install -y e2fsprogs*      //安裝依賴包

# wget http://nchc.dl.sourceforge.net/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
---------------------
extundelete version 0.2.4
libext2fs version 1.41.12
Processor is little endian.
---------------------

4、恢複資料

執行個體:假如我們誤刪除檔案為 test.txt,所在分區為/dev/sdb。
1)掃描檔案
# /usr/local/extundelete/bin/extundelete  /dev/sdb --inode 2    //掃描哪些檔案被刪除了
2)恢複檔案

# /usr/local/extundelete/bin/extundelete --restore-file test.txt /dev/sdb

3)查看檔案
恢複的檔案在目前的目錄下的  RECOVERED_FILES/ 目錄下  
# ls ./RECOVERED_FILES/  

可以看到 test.txt 檔案。

 

注意:

如果想恢複整個分區上的檔案,則可以執行以下命令
# /usr/local/extundelete/bin/extundelete --restore-all  /dev/sdb
恢複後的檔案也在  ./RECOVERED_FILES/  目錄下。

 

5、後續工作

1)重新掛載該分區為可寫。
2)備份重要資料。
3)覆蓋我們恢複出來的資料。
4)重啟伺服器,恢複之前關閉的各種服務。

 

 

本文出自 “M四月天” 部落格,請務必保留此出處http://msiyuetian.blog.51cto.com/8637744/1707646

CentOS系統復原誤刪除的檔案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.