cephdata-recovery

Recover Data from Deleted RBD Volume?


Is there any way to recover data from deleted RBD volume in Ceph? thanks

$ ceph osd map pool-name csi-vol-65c11863-32e1-11eb-a202-cab20b4e04f6
osdmap e2248 pool 'pool-name' (8) object 'csi-vol-65c11863-32e1-11eb-a202-cab20b4e04f6' -> pg 8.e5d09b91 (8.11) -> up ([5,4], p5) acting ([5,4], p5)

Solution

  • AFAIK, the answer is No. However, I am citing a following explanation from the source that may be helpful for you:

    Consider the way Ceph stores data... each RBD is striped into chunks (RADOS objects with 4MB size by default); the chunks are distributed among the OSDs with the configured number of replicates (probably two in your case since you use 2 OSD hosts). RBD uses thin provisioning, so chunks are allocated upon first write access. If an RBD is deleted all of its chunks are deleted on the corresponding OSDs. If you want to recover a deleted RBD, you need to recover all individual chunks. Whether this is possible depends on your filesystem and whether the space of a former chunk is already assigned to other RADOS objects. The RADOS object names are composed of the RBD name and the offset position of the chunk, so if an undelete mechanism exists for the OSDs' filesystem, you have to be able to recover file by their filename, otherwise you might end up mixing the content of various deleted RBDs. Due to the thin provisioning there might be some chunks missing (e.g. never allocated before).

    However, there is still some hope. The Ceph book called Mastering Ceph has given some hints to recover the data as following:

    there are tools that can search through the OSD data structure, find the object files relating to RBDs, and then assemble these objects back into a disk image, resembling the original RBD image.

    May be you need to find the right tool in Ceph source code.