Operations 9 min read

When rm -rf Wiped a Production Server: Recovering MySQL Data with ext3grep and Binlog

A production server suffered catastrophic data loss after an rm -rf command erased the entire disk, prompting a frantic recovery effort that leveraged ext3grep, extundelete, and MySQL binlog to restore critical MySQL tables and bring the service back online.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
When rm -rf Wiped a Production Server: Recovering MySQL Data with ext3grep and Binlog

Accident Background

A junior engineer was tasked with installing Oracle on a production server. While experimenting, she realized the installation was incorrect and attempted to uninstall it using a command that removed the Oracle base directory: rm -rf $ORACLE_BASE/* Because the $ORACLE_BASE variable was unset, the command became rm -rf /*, deleting the entire filesystem—including Tomcat, MySQL, and other services.

The mistake erased all data on the disk, leaving only a few large log files.

Initial Recovery Attempts

After discovering the loss, the team mounted the affected disk on another server and inspected the damage. Offline backups were only 1 KB and outdated, providing no usable data.

Remembering a previous case, the team tried ext3grep , a tool capable of recovering files from ext3 filesystems. ext3grep /dev/vgdata/LogVol00 --dump-names The command listed all deleted files, giving hope that the data could be recovered.

Since ext3grep cannot restore by directory, the team used the --restore-all option, but ran out of space on the target volume, resulting in partial restores. ext3grep /dev/vgdata/LogVol00 --restore-all They then redirected the file list to a text file, filtered MySQL‑related entries, and wrote a shell script to restore each file individually:

while read LINE
do
  echo "begin to restore file $LINE"
  ext3grep /dev/vgdata/LogVol00 --restore-file $LINE
  if [ $? != 0 ]; then
    echo "restore failed, exit"
    # exit 1
  fi
done < ./mysqltbname.txt

The script recovered about 40 files, far fewer than the ~300 MySQL files needed.

Using Binlog for Final Recovery

Realizing the remaining data might be in MySQL binary logs, the team located three binlog files ( mysql-binlog0001, mysql-bin.000009, mysql-bin.000010) and attempted to restore them.

mysqlbinlog /usr/mysql-bin.000010 | mysql -uroot -p

The binlog import succeeded, and the application data reappeared.

Post‑mortem and Lessons Learned

Never let an untrained person perform critical operations on a production system without clear instructions.

Ensure automated backups are verified and retained; a 1 KB backup is useless.

Implement monitoring and alerting to detect anomalies early.

Never operate as root for routine tasks; use least‑privilege accounts.

Through teamwork, the incident was resolved, but the experience highlighted the importance of proper procedures, reliable backups, and rapid recovery tools.

ext3grep rescue
ext3grep rescue
Data recovery illustration
Data recovery illustration
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mysqlData Recoveryext3grep
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.