how can i restore data from bad sector external hard drive
Clone your drive sector-by-sector using a tool that knows how to work around bad sectors, and then use data recovery software on the clone.
Some freeware cloning tools are ...
Comparison between ddrescue and dd_rescue:
Ddrescue can perform multipass cloning. It clones the easy sectors on the first pass, and attempts the more difficult ones on subsequent passes. It can also clone your drive in reverse, thereby disabling lookahead caching. It keeps a log, allowing it to resume after an interruption.
The following thread discusses various freeware and commercial cloning tools:
It is important to understand exactly what cloning means. Cloning is the copying bit by bit from one partition or disk to another. They don't care or even know if a sector is bad or data is corrupt. They just copy the bits, headers, disk signatures, partition tables, volume managers, file system, data, everything.
The dd_rescue tool is not a cloning tool, it is an imaging tool, which is different.
If you want to rescue bad bits or sectors, probably the best is Steve Gibson's Spin Rite DOS commercial program, which looks at every bit and attempts to determine by the magnetic field what was or supposed to be there. Takes a long time to analyze a large disk, costs' $89, but is one of the best.
You could also try this one and it is free for home use and John is right about Steve Gibson and Spin Rite. Steve has a great site, you should check it out.
I beg to differ about SpinRite.
SpinRite, and HDD Regenerator, have their devotees and detractors. I don't fit neatly into either camp, but I don't believe that many of the claims made by Steve Gibson are applicable to modern drives. In fact SpinRite's screenshots are limited to drives that date back to 20 years ago (when I first encountered SpinRite).
AIUI, SpinRite will attempt to recover the data in a difficult sector by hammering away at up to several thousand times while hoping for one good read. After all this, SpinRite writes the data back to the problem drive instead of to a clone.
AIUI, modern high capacity drives often suffer from head problems rather than bad media. Data recovery professionals will all tell you that you must not stress a drive that has "weak" heads. Doing so risks accelerating their total failure. Instead you are best advised to clone (ie image) your drive, sector-by-sector, as fast as possible, without dwelling on difficult sectors. That's why ddrescue (freeware) is a much better tool than SpinRite.
Some drives, such as WD's Tornado family (eg WD5000AAKS) will behave as if they have bad media or bad heads, but the fault is actually on the board. Therefore SpinRite is completely useless in such cases.
Steve Gibson makes claims regarding the ability of his software to influence the drive's AGC, but this is impossible according to what I've been told. Another claim that he makes is that SpinRite can approach a difficult sector from different directions, with the result that the head ends up slightly off to one side of the track. This technique is really only meaningful for the stepper motor drives that were the norm 2 decades ago. Approaching a track from different directions could account for backlash in the gearing, or it could help to compensate for track shift due to temperature. None of this is applicable to voice coil drives, as these use an embedded servo signal to position the head. In fact, AIUI, the drive automatically and transparently performs its own "micro-jogging" to either side of the track during its read retries.
In short, I believe that SpinRite, today, is at best useless, and at worst dangerous. In my day, 20 years ago, it was a great tool.