0

There is damaged SD card, some problems with connectors I guess. After plugging in this SD Card mounts and becomes readable for about 30 seconds and data is reachable for download then for some time the card is gone, then connects again and falls ... and so on.

My question is: how can I read data from the SD card? I see it like this: one should write some script in bash, where data would be downloaded in infinite loop, using

dd

or

cp

but for me is unclear, what to do if SD umounts and "goes away".. how can I "remember" the stop point to contiue again when SD card returns? If use command

 sleep()

then what should stand for argument? When the card connects again is unclaer, it can be 20 seconds, 30, 44 seconds.. and how to continue the process from the point of stop? There is a way to delete copied data, but it is troublesome.

What do you think which way is the best one and how script should be organized?

Thank you in advance!

John
  • 297

1 Answers1

2

As cp and dd are no good when it comes to resume a transfer I would use

rsync -avP <yoursdcardmount> <dest>

and repeat it until it returns no error

It will copy as much as it can then it will restart where it ended. Finally I'll try to check integrity

rsync -avc <yoursdcardmount> <dest>

If you come to realise that accessing a particular file is the source of the error then add it to an exclude list.

M4rty
  • 1,153
  • Thank you very much! It is working, but there is one drastic problem unfortunately. If some huge file starts downloading (let's say around 600MB) then connection drops during this, then raises again, the same file starts downloading again, then connection falls then situation repeats all over again and the whole proccess stops by this huge file. It cannot be downloaded and cannot be skipped... Do you have some ideas to solve it...? – John Jul 22 '17 at 19:01
  • Should I leave it undownloaded by –exclude , or can I somehow get it? – John Jul 22 '17 at 19:11
  • @john the -P parameter stands for partial, temporary file are left on destination and the copy of huge files should resume from where it stops, not from the beginning. If it refuses to resume, something is wrong with this file, depending on his type, the partial copied file might contain information of value but I don't know anyway to recover the rest, exclude it for now, then you'll have a list of the missing ones. I don't have ideas for those maybe something with dd an noerr option knowing the start sector and the size (fragmentation excluded), it could be the aim of an other question. – M4rty Jul 22 '17 at 21:23