Trying to recover from a bad RAID rebuild
May 24, 2012 6:42 AM Subscribe
I have a NAS appliance that crashed last weekend. The IT guys apparently / maybe didn't recover it in the right way? There's about 50,000 directories in a "lost+found" directory each with a numeric name like "#4289756". It looks as if all the missing files are within these directories, each with the original date and owner information (Linux). I need to organize them so they are findable to the staff.
My goal is to copy / move these files into a structure so that each employee has their own folder with their own files, and each folder is further divided by month.
The appliance itself is running a Busybox, a stripped down Linux version that only supports a subset of the typical Bash commands. I thought I could use a script with the "find" command to sort them by owner and date and then pipe that to "-exec cp" to the appropriate place, but it looks like Busybox doesn't have that ability.
I have:
1. A network of Windows machines
2. A working knowledge of Bash scripting (no expert, mind you)
3. The ability to install a Linux VM on one of the Windows machines
4. Cygwin already installed on one of them
I get the concept of what needs to be done, but the devil is in the details, and I could sure use some help. Anyone?
posted by nedpwolf to technology (6 answers total)
This is not the fault of your IT people in other words.
Hacky, partially tested commandline follows:
cd /lost+found ; for i in *; do USER=`ls -l $i | awk '{print $3}'`; mkdir -p /home/$USER/recovered ; cp -a $i /home/$USER/recovered/$i ; done
If you run that on the NAS, it should recursively copy everything owned by each user in lost+found into a 'recovered' directory in their home directory on the NAS. You may need to change /home to wherever the NAS is storing all the home directories.
posted by pharm at 7:29 AM on May 24, 2012 [3 favorites]