centos誤刪除檔案如何恢複

來源:互聯網
上載者:User

標籤:

當意識到誤刪除檔案後,切忌千萬不要再頻繁寫入了,否則你的資料恢複的數量將會很少。 而我們要做的是,第一時間把伺服器上的服務全部停掉,直接killall 進程名 或者 kill -9 pid 。 然後把誤刪除檔案所在分區,重新掛載成ro,唯讀 (mount  -o ro  /dev/sdb2  /data/)。

然後我們需要去下載和安裝一個工具叫做   extundelete

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

2.下載並安裝extundelete
# wget http://nchc.dl.sourceforge.net/p ... elete-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.
---------------------

假如我們誤刪除檔案所在分區為/dev/sdb2  
恢複步驟如下:

/usr/local/extundelete/bin/extundelete  /dev/sdb2 --inode 2    //可以掃描哪些檔案被刪除了

假如我們有一個檔案叫做1.txt被刪除了。 那麼恢複它的命令為:

/usr/local/extundelete/bin/extundelete --restore-file 1.txt  /dev/sdb2

被恢複的檔案在  目前的目錄下的  RECOVERED_FILES/ 目錄  
ls  ./RECOVERED_FILES/  可以看到有1.txt


而想恢複整個分區上的檔案可以這樣:
/usr/local/extundelete/bin/extundelete --restore-all  /dev/sdb2 

恢複後的檔案也是在   ./RECOVERED_FILES/  下,能否恢複就看你的運氣好不好了。 


當然後續工作還有:
1. 重新掛載該分區為可寫
2. 備份一下重要資料
3. 覆蓋我們恢複出來的資料
4. 重啟伺服器,恢複各種服務

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.