btrfscue is an advanced data recovery tool for the BTRFS filesystem. Despite
being a state of the art filesystem, at the time when I started writing this
(Q2 2011), BTRFS did not have a stable fsck tool that is capable of restoring
a filesystem to a mountable state after a power failure or system crash.
Recently, this situation has somewhat improved with the btrfs restore
command. Unlike this official tool, btrfscue is designed to be able to restore
data from disk images that were obtained from faulty storage devices or if all
superblocks were overwritten inadvertently.
Being a recovery tool, btrfscue works best on disk images and will write recovered data to a directory. It can thus be used to convert BTRFS filesystems to any other filesystem supported by the host OS. It will also recover recently deleted files and directories and aid in BTRFS filesystem forensics.
As the version number 0.5 implies, this software is pretty much in alpha state. In fact, the repository you're looking at now is a complete rewrite of an earlier attempt that was written in C++ as early as 2011 (so don't let the copyright years fool you :)).
This works:
This definitely does not work:
General way to build and install via go install
:
go install blichmann.eu/code/btrfscue/cmd/btrfscue@latest
To build from a specific revision/branch/tag, not using go install
:
mkdir -p btrfscue && cd btrfscue
git clone --recurse-submodules https://github.com/cblichmann/btrfscue.git .
# Optional: checkout a specific rev./branch/tag using i.e. git checkout
make
You may want to create a symlink to the binary somewhere in your path.
At the moment, only building Debian packages is supported. Just run make deb
to build.
btrfscue command-line syntax is generally as follows:
btrfscue SUBCOMMAND OPTION...
Data recovery with btrfscue is divided in stages:
If you suspect physical damage, use a tool like ddrescue to dump the
contents of the damaged filesystem to another disk. Otherwise, the
standard dd
utility will do just fine. The following steps assume the
disk image is named DISKIMAGE.
If you don't have enough physical storage space, btrfscue will also
directly work with the device file. However, THIS IS NOT RECOMMENDED
IN CASE OF SUSPECTED PHYSICAL DAMAGE. Although btrfscue never writes
to the device, it may stress the drive too much and may render further
recovery attempts impossible. This is even true of damaged SSDs since
the flash controller may decide at any time to shutdown the device for
good.
Build a list of possible ids to help identify the filesystem id for the filesystem that is to be restored by applying a heuristic. This will output a list of filesystem ids along with the number of times the respective id was found while sampling the disk image.
btrfscue identify DISKIMAGE
Save metadata for later analysis. This may take a long time to finish as the whole image is being scanned. You need to specify the filesystem to look for by using the --id parameter with a filesystem id FSID.
btrfscue recon --id FSID --metadata metadata.db DISKIMAGE
Inspect the metadata dump to help decide what to restore later.
btrfscue --metadata metadata.db ls /
...
Alternatively, if you're on Linux or macOS, you can FUSE-mount a "rescue" of the filesystem metadata:
btrfscue --metadata metadata.db mount MOUNTPOINT
Explore the metadata from another shell. Type CTRL+C to unmount.
Restore the actual data. This is work-in-progress. You can use the mount command to copy files that are no bigger than the filesystem block size.
btrfscue version 0.6 Copyright (c)2011-2023 Christian Blichmann mail@blichmann.eu
btrfscue is licensed under a two-clause BSD license, see the LICENSE file for details.