DebugFS Extraction of Corrupt EXT Data – Folders with Spaces
#################################################

In this example we will extract the following folders
/c/common/KVKG Red Burritos/
/c/design/DYNAMIC
/c/plans/McDownload/Current VRRP Kos/
/c/users/

Note that they are mounted on /c

As far as the block device is conserned the files are actually
/common/KVKG Red Burritos/
/design/DYNAMIC
/plans/McDownload/Current VRRP Kos/
/users/

Watch how spaces are needed to be treated. If you ever used debugfs you know its very VERY syntax annoying. You gotta get every slash down correctly. Even the quotes

Read the comments as they have good info, first on how to make sure you know your using the correct syntax we will do a simple “ls” internally in the code.

cat /root/backup-debugfs.sh

#!/bin/bash
#
# This will use debugfs to try and extract data out of a curropt filesystem
# In this case the filesystem mounts however when copying the 1.4TB of data using "cp" only 600 gigs get copied
# The remaining are "input/output errors" due to the underlying RAID that was curropt to due drives being moved around
#
# PRE-REQ: debugfs (to get "apt-get install e2fsprogs")
# PRE-REQ: make sure that the filesystem is unmounted
#
# FILENAME: /root/backup-debugfs.sh
# PREPARE LIKE SO: chmod +x /root/backup-debugfs.sh
# RUN LIKE SO: /root/backup-debugfs.sh
# BEST TO RUN WITH NOHUP (so can close putty and it still runs) MADE STARTER SCRIPT FOR THAT
# RUN STARTER SCRIPT LIKE SO: /root/starter-debugfs.sh
#
# Extracting the following folders from the data volume /dev/c/c which usually mounts /c
# Below is how they look like when they are normally mounted
# When refering to them with debugfs omit the /c part
# Watch how folders with spaces are treated
#
# HOW FS LOOKS WHEN NORMALLY MOUNTED:
# /c/common/KVKG Red Burritos/ 
# /c/design/DYNAMIC
# /c/plans/McDownload/Current VRRP Kos/
# /c/users/
#
# LOCAL/BACKUP DEST (making these folders for dump, these folder should be empty):
# /mnt/1Backup/common/
# /mnt/1Backup/design/
# /mnt/1Backup/plans/McDownload/
# /mnt/1Backup/users/
#
# To list the files in each folder had to do like so:
# debugfs -R "ls \"/common/KVKG Red Burritos/\"" -c /dev/c/c
# debugfs -R "ls \"/design/DYNAMIC/\"" -c /dev/c/c
# debugfs -R "ls \"/plans/McDownload/Current VRRP Kos/\"" -c /dev/c/c
# debugfs -R "ls \"/users/\"" -c /dev/c/c
#

# --- script begin---
# 1st i list how to dump the folder into current folder (current folder should be empty, and not contain the relative path to be dumped)

echo "###########################################################################################"
echo "=======START======= - DATE: [`date`] [`date +%s`]"
echo "--space-reading-human-readable--"
df -Ph
echo "--space-reading--"
df -P

echo "=======(1/4) common/KVKG Red Burritos======= - DATE: [`date`] [`date +%s`]"
# into empty folder (cant have a folder called 'KVKG Red Burritos' in destination folder):
# debugfs -R "rdump \"common/KVKG Red Burritos\" ." -c /dev/c/c
# into this folder works (cant have a folder called 'KVKG Red Burritos' in destination folder):
mkdir -p /mnt/1Backup/common
debugfs -R "rdump \"common/KVKG Red Burritos\" /mnt/1Backup/common/" -c /dev/c/c

echo "=======(2/4) design DYNAMIC======= - DATE: [`date`] [`date +%s`]"
# into empty folder (cant have a folder called 'DYNAMIC' in destination folder):
# debugfs -R "rdump \"design/DYNAMIC\" ." -c /dev/c/c
# into this folder works (cant have a folder called 'DYNAMIC' in destination folder):
mkdir -p /mnt/1Backup/design
debugfs -R "rdump \"design/DYNAMIC\" /mnt/1Backup/design/" -c /dev/c/c

echo "=======(3/4) plans/McDownload/Current VRRP Kos======= - DATE: [`date`] [`date +%s`]"
# into empty folder works (cant have a folder called 'Current VRRP Kos' in destination folder):
# debugfs -R "rdump \"plans/McDownload/Current VRRP Kos\" ." -c /dev/c/c
# into this folder works (cant have a folder called 'Current VRRP Kos' in destination folder):
mkdir -p /mnt/1Backup/plans/McDownload
debugfs -R "rdump \"plans/McDownload/Current VRRP Kos\" /mnt/1Backup/plans/McDownload/" -c /dev/c/c

echo "=======(4/4) users======= - DATE: [`date`] [`date +%s`]"
# into empty folder works (cant have a folder called 'users' in destination folder):
# debugfs -R "rdump users ." -c /dev/c/c
# into this folder works (cant have a folder called 'users' in destination folder):
mkdir -p /mnt/1Backup/
debugfs -R "rdump users /mnt/1Backup/" -c /dev/c/c

echo "=======END======= - DATE: [`date`] [`date +%s`]"
echo "--space-reading-human-readable--"
df -Ph
echo "--space-reading--"
df -P
echo "###########################################################################################"

 

Leave a Reply

Your email address will not be published. Required fields are marked *