Data recovery from MDADM RAID 1

Hello,

I accidentally erased my files from my MDADM raid when I created a Docker (new to Docker) container and mapped my raid but after that all files in the raid disappeared. The discs are not currently being written or read. I want to ask what is the way I can recover my files? Unfortunately I don’t have a backup. Also I am open to any suggestions even to attach disks to Windows machine. This is my Docker compose config file which I used → Nextcloud-Docker - Pastebin.com

My setup:

OS: Ubuntu server 20.04LTS

2xHDD 1TB in MDADM RAID1 + 1xSSD 500GB OS drive

FS type: ext4 not encrypted

Thanks in advance.

1 Like

here are some commands:

mdadm --detail /dev/md0

mdadm --assemble --verbose /dev/md0 your raid disks(/dev/sda /dev/sdb /dev/sdc /dev/sdd) --update=devicesize
sudo e2fsck /dev/md0 -y

undeleting a file from mdadm raid is no different than undeleting a file from anything else really.

try extundelete --restore-all

see manual page for extundelete for other options:
https://manpages.debian.org/testing/extundelete/extundelete.1.en.html

with SSDs and thin provisioned volumes you may be unlucky if trim kicked in in the meantime, and unmapped the actual storage blocks so they can be reclaimed and recycled, but this shouldn’t be a problem with just mdadm on HDDs (by default anyway).

consider converting your ext4 to btrfs (once you’re done with recovery) - even if you stick to mdraid and don’t get any benefit from from any additional raid1 integrity features present in btrfs, there’re are some handy utilities that can help you maintain a certain number of periodic snapshots - handy in cases you mess things up like this in the future.
… or consider just using btrfs in raid1 mode if you give up on recovery

1 Like