Skip to content

pmirek/Partial-File-Recovery

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

[P]artial [F]ile [R]ecovery in case of badSector, HDD Error

Overview

Software is intended to recover or clone files or data from a bad drive, written in pure C, by doing the following:

  • Unlike other similar softwares, default action is Fast Forward which is a 1M buffered copy. Therefore the software only fallback to Block Mining aka sector-to-sector copy when badblock found and for a short period as recovery necessary (sector size can be adjusted), this mechanism give insane recovery speed on huge files or even block devices.
  • In recovery mode, there is an option to define max retry, which intended to probe [x] times the same sector to recover badblock, there is a little chance to succeed anyway. Also if the block could not be recovered the software will fill a specified character instead (default: 0x00) and continues read, this mechanism allows to partially recover the file.

What can be recover partially

  • Block devices such as /dev/sda /dev/da0 and so on..
  • innoDB tables (*.ibd) recovery possible on small amount of data loss, combinated with innodb_recovery_mode = 6 there are a great chance to able to dump the database with only a few rows missing.
  • Video Files, Mp3 Files, Pictures, Text Files, Anything.
  • Complete Block Devices (Clone)

What can NOT be recover

  • Deleted files, this software intended to use on files that affected by filesystem error or HDD error.
  • Partitions, the software cannot alter the partition or Disk layout, use testdisk software instead

The story behind it

  • I used to solved some dataloss issues in the past and I wanted a tool which is easy to use and understandable.
  • ddrescue was too complex and slow for me also the output size sometimes did not match.
  • I wanted a tool that is native and portable (windows, freebsd, linux)

Well Proven

  • I restored innoDB databases multiple times with innodb_recovery_mode
  • I cloned many disks with badsectors presents, then I rescued with testdisk toolset.
  • Simplier and faster than it's competitors, time is important.

Compilation

  • on linux system: gcc -o pfr64 pfr.c or for 32bit: gcc -m32 -o pfr32 pfr.c
  • cross-compile windows: x86_64-w64-mingw32-gcc -o pfr64 pfr.c or for 32bit: i686-w64-mingw32-gcc -o pfr32 pfr.c
  • freebsd: clang -o pfr64 pfr.c or for 32bit: clang -m32 -o pfr32 pfr.c

Usage

[P]artial [F]ile [R]ecovery Version: 1.6r
Author: Viktor Hlavaji aka DaVieS, [email protected] | Licensed under: GNU/GPLv3

Usage: ./pfr [source_file] [dest_file] [try = 1] [fill = 00] [skip = 512] [seek = 0] [endpos = 0]

 - source_file: The file that needs recover
 - dest_file: Output file will generated by this software
 - try: (Optional) number of attempts to read a badSector
 - fill: (Optional) unrecovered bytes will replaced by hexCode 0x[XX]
 - skip: (Optional) On read error skip the next (x) bytes, should match with sectorsize or blocksize
 - seek: (Optional) Start reading from seek position
 - endpos: (Optional) Reading until end position

Software Output:
Action | Current Block: 315385359, Round Left: 1, lost: 26127, recovered: 12, acquired: 315359232, Progress: 60.154984
 |       |                         |              |            |              |                    |-> Progress
 |       |                         |              |            |              |-> Bytes read successfully
 |       |                         |              |            |-> Bytes magically recovered
 |       |                         |              |-> Unrecovered Bytes that filled with a specified character
 |       |                         |-> Retry Count Left
 |       |-> Show current position
 |-> [Fast Forward] when continous data read available, or [Block Mining] when recovery in action

Example: ./pfr ./broken_file.mp3 ./broken_file_fix.mp3
Example: ./pfr /home/music/broken_file.mp3 /tmp/broken_file_fix.mp3 2 00

(*nix only) Example: ./pfr /dev/sda /dev/sdb 2 00 512
(*nix only) Example: ./pfr /dev/sda1 /dev/sdb2


When cloning 4K baddrive using the matching sectorsize like '4096' as skip argument will faster the progress

Sample Output

[root@vhost damaged]# ./pfr64 ib_logfile1 ib_logfile1.fix


[P]artial [F]ile [R]ecovery Version: 1.0r
Author: Viktor Hlavaji aka DaVieS, [email protected] | Licensed under: GNU/GPLv3


Source File Opened Successfully: ib_logfile1
Destination File Opened Successfully: ib_logfile1.fix
Total Bytes to recover: 524288000
badBlock Try Count: 1
badBlock fill char: 0x00
badBlock skip count / sectorsize: 1

Fast Forward | Current Block: 0, Round Left: 1, lost: 0, recovered: 0, acquired: 0, Progress: 0.000000
Fast Forward | Current Block: 271253504, Round Left: 1, lost: 0, recovered: 0, acquired: 271253504, Progress: 51.737499
Block Mining | Current Block: 313786368, Round Left: 0, lost: 0, recovered: 0, acquired: 313786368, Progress: 59.850002
Block Mining | Current Block: 313819234, Round Left: 0, lost: 98, recovered: 0, acquired: 313819136, Progress: 59.856270
Block Mining | Current Block: 313819309, Round Left: 0, lost: 173, recovered: 0, acquired: 313819136, Progress: 59.856285
Block Mining | Current Block: 313819445, Round Left: 0, lost: 309, recovered: 0, acquired: 313819136, Progress: 59.856308
Block Mining | Current Block: 313819447, Round Left: 0, lost: 311, recovered: 0, acquired: 313819136, Progress: 59.856312
Block Mining | Current Block: 313819455, Round Left: 0, lost: 319, recovered: 0, acquired: 313819136, Progress: 59.856312
Block Mining | Current Block: 313819473, Round Left: 0, lost: 337, recovered: 0, acquired: 313819136, Progress: 59.856316
Block Mining | Current Block: 315390216, Round Left: 0, lost: 30984, recovered: 0, acquired: 315359232, Progress: 60.155910
Block Mining | Current Block: 315391149, Round Left: 0, lost: 31917, recovered: 0, acquired: 315359232, Progress: 60.156090
Block Mining | Current Block: 315439742, Round Left: 0, lost: 32768, recovered: 0, acquired: 315406974, Progress: 60.165356
Finished | Current Block: 524288000, Round Left: 0, lost: 32768, recovered: 0, acquired: 524255232, Progress: 100

Under License

GNU/GPLv3

About

learning C & OS/file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%