Hi,

I tried to recover an accidentally deleted text file from a btrfs volume using 
the trusty old 'grep --text -C 500' method and failed, since the filesystem was 
compressed. So I wrote a shell script that uses btrfs-progs for a proper 
undelete functionality.

Attached is the script that implements a working btrfs-undelete using the find-
root and restore tools from btrfs-progs. It is fairly complete and solid and 
it even has some command  line help. It needs bash and common unix utilities 
(sed, grep, wc, dirname, sort). I have successfully used it to recover a 
couple of files I deleted accidentally and was able to recover 2/3 of them just 
fine. The rest was zero-sized, I assume that's because the file blocks have 
already been reused.

If you like it, feel free to add it to btrfs-progs. I've chosen GPLv2 or later 
as license, as that's what btrfs-progs seems to use.

Please CC me on replies, I am not subscribed (and don't intend to).

-- 
Mit freundlichen Grüßen,

        Jörg Walter

Attachment: btrfs-undelete
Description: application/shellscript

Reply via email to