Linuxファイル復旧

大事なファイルを rm するありがちなボケをかましてしまい、やり方調べたのでメモ。
extundelete を使うのだが、サーバ環境にあまり影響を与えたくなかったので、なるだけ無難な方法でやったつもり。
rootで以下を実行。

cd /tmp/
curl -L -o e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm "ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm"
rpm -ivh e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm 

curl -L -o extundelete-0.2.4.tar.bz2 "http://sourceforge.net/projects/extundelete/files/latest/download"
tar xjvf extundelete-0.2.4.tar.bz2
cd extundelete-0.2.4
./configure --prefix=/root/rhase/extundelete
make
make install

なお、e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm の依存関係と gcc-c++ はインストール済みであった。
この後、

/root/rhase/extundelete/bin/extundelete --after 1447727400 --restore-all /dev/sda6

とかやって復旧を実行。

WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.
The partition should be unmounted to undelete any files without further data loss.
If the partition is not currently mounted, this message indicates 
it was improperly unmounted, and you should run fsck before continuing.
If you decide to continue, extundelete may overwrite some of the deleted
files and make recovering those files impossible.  You should unmount the
file system and check it with fsck before using extundelete.
Would you like to continue? (y/n) 

とかなんだか怖そうなWarnが出たが y で実行。復旧できた。
ただ、ファイルによっては全然別なファイル名で復旧されてたやつもあった(秘密鍵ファイルが known_hosts~ というファイル名になってた)。必ずしもきれいに復旧できる訳ではなさそう。当然ながら、「もう復旧できないinode」みたいなメッセージもいっぱい出てた。

補足

なるだけ環境に影響を与えたくなかったので、e2fsprogs-devel は上記バージョンを使用。(yum すると他のパッケージがバージョン合わせのためにUpgradeされてしまうので)
上記では curl で落とす手順を書いているが、今回は ftp のポートが空いてないためか、サーバに接続できなかったので、自端末で落としたものをSCPした。

# wget "ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm"
--2015-11-17 17:34:59--  ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm
           => `e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm'
mirror.switch.ch をDNSに問いあわせています... 失敗しました: 名前解決時の一時的な失敗.
wget: ホストアドレス `mirror.switch.ch' を解決できませんでした。

ほんとはインストール先も自分用のパス(/root/rhase)にしたかったが、再配置不可だった…

# rpm -ivh --prefix=/root/rhase/e2fsprogs-devel e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm                                                                                
警告: e2fsprogs-devel-1.41.12-18.el6_5.1.x86_64.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
エラー: パッケージ e2fsprogs-devel は再配置できません。