January 11, 2007

Extracting a Single file from Sharp’s Backup

Posted in Linux/Zaurus Tips and Tricks at 7:33 pm by sdjf

Ever find yourself in the position of having just a few corrupt files, and not want to use Sharp’s backup utility to take your Zaurus back to last week’s or last month’s backup?

Well, the backups in Sharp ROM 2.38 are simple tar files, and you can, indeed, extract just the files you need.

This will need to be done from a console or terminal application. If you do not have one, then see my discussion at http://sdjf.esmartdesign.com/tutorial.html.

The first step is to get the name and location of your most recent backup. Use the find command to do this. Be sure to put quote marks in the find command, as shown:


bash-2.05# find / -name "*.backup"
/mnt/cf/2006-12-10-19-51.backup
/mnt/cf/2006-12-11-22-03.backup
/mnt/cf/2006-12-22-01-36.backup
bash-2.05#

Then you need to to get a listing of the precise pathname to the file(s) you want.

In my case, there was just one corrupt file, so I funneled the output of tar's listing through grep so I could locate the pathname quickly:


bash-2.05# tar -tf /mnt/cf/2006-12-22-01-36.backup | grep index | grep sl5500 | grep Inbox | grep data
home/root/tkcMail/.indices/Local/Inbox/sl5500/index/data
bash-2.05#

I then entered the name of the file I wanted as follows, choosing to put it in a temporary file on my CF card, in case of problems writing directly to internal memory. The following command was all entered on a single line:


bash-2.05# tar -xvOf /mnt/cf/2006-12-22-01-36.backup home/root/tkcMail/.indices/Local/Inbox/sl5500/index/data > /mnt/cf/newindex &
bash-2.05#

I then copied the new file into place in internal memory:


bash-2.05# cp -p /mnt/cf/newindex /home/root/tkcMail/.indices/Local/Inbox/sl5500/index/data
bash-2.05#

And, instead of tkcMail crashing when I tried to open the sl5500 folder (which had been my clue the file was corrupt), it opened up the sl5500 folder and let me read email without a hitch.

How did the file get corrupted? I do not know for sure, but my best guess is that the folder was open during a total crash when I had to reboot, or some poorly behaved program overwrote it.

sdjf

Advertisements
%d bloggers like this: