20
13
How do I undelete (recover) a deleted file on a btrfs partition?
I have not taken a snapshot yet, so I can't use that feature. I know there are some tools for other Linux file systems, but google has not turned up anything specific to btrfs. I came across one vague mention that btrfs includes an undelete tool, but I can't find it. Before trying tools for another file system, I'm asking here.
More info:
- The (two) deleted files were deleted by a remote
rsync
command gone wrong. - These were small plain text files.
- I know the names of the files.
- I might be able to remember some strings in the files.
- The disk is a regular HDD, but it is large (2TB).
- I'm running Kubuntu 12.04 (beta2) with all latest updates.
- I have not written any new data to the partition the files were deleted from.
- I don't have a snapshot or a backup of these files. (The last backup is just a few hours older than these files.)
- Strangely, a COW file system seems to have fewer file undelete options than ext3/4...
3Worth noting is that the said script has at least one path hardcoded (presumably by mistake) and has a few other problems, so buyers beware that it must be edited before use. – gamen – 2014-07-15T06:32:02.953
3
Here's a cleaned up version of the original script: https://gist.github.com/Changaco/45f8d171027ea2655d74
– Changaco – 2015-10-30T17:03:55.4771"As it is licensed under GPLv2, I cannot include it here" - maybe you should read what the GPLv2 says, because that makes no sense whatsoever. – slang – 2016-12-12T23:37:38.480
4@slang maybe you should read the terms of service of this site? Contributions must be licensed under the Creative Commons Attribution Share Alike 3.0 license. – suriv – 2017-01-07T16:37:33.460
@suriv - I guess I can understand their reasons for doing that, but that's pretty annoying. Especially since CC-BY-SA is only slightly more restrictive than the GPL (aside from GPLv3s patent stuff). – Omnifarious – 2018-09-08T06:53:26.283
Note old versions of btrfs-find-root don't work very well - I had this going for hours at 100% CPU. This was on 4.10. Upgrading to 4.19 Fixed the problem. – Luciano – 2019-05-19T16:10:35.030