Ever find yourself in the position of having accidentally erased an entire directory from your Zaurus, along with it's contents, and not want to use
Sharp's backup utility to take your entire Zaurus back to last week's or last month's backup?
As I mentioned in my post about retrieving single files from
Sharp's backup, the backups in
Sharp ROM 2.38 are simple
tar files. In the discussion below, I will show how to extract just a single directory.
This will need to be done from a console or terminal application. If you do not have one, then see my discussion at http://www.sdjf.esmartdesign.com/tutorial.html.
The first step is to get the name and location of your most recent backup. You can do this with the
find command. An advantage of using the
find command to do this, is that it will find your backups wherever they are on your system, whether they are on a CF card or SD card or both.
bash-2.05# find / -name "*.backup"
In my case, I already know my most recent
backups were made in June 2007, and are on my CF card.
So, I will just use the
command to search for backup filenames starting with "2007-06" which are
located on my CF card:
bash-2.05# find /mnt/cf/ -name "2007-06*.backup"
Alternately, I could just use the "ls" command to show me the names of the most recent backups on my CF card. This time, I am
piping the results through the "head -n3" command, so I just get the names of my three most recent backups:
bash-2.05# ls -t /mnt/cf/*backup| tail -n3
If you do not know how to type a
on the sl5500's hardware keyboard, you can type a
pipe by simultaneously pressing the
space key and the
up arrow key (which is on the left side of your keyboard,
above the function (Fn) key).
Once you decide which backup to use, you need to to get a listing of the precise pathname to the directory you want.
In this example, I want the contents of just one directory.
The output will be long because there are many files in this directory. So,
I am first
piping the output of
tar's listing through
grep so I can locate the pathname
quickly. I then also
pipe that output through the "head" command, which shows me the
path to the directory, and the first 9 files in it.
bash-2.05# tar -tf /mnt/cf/2007-06-21-09-19.backup | grep Drafts | grep cur | head
While I could have achieved the same results in
this case by using a
"head -n1", the
above example can be used to confirm you have the
right directory before extracting it. If you are
sure your sequence of grep's is correct,
then the following is an option:
bash-2.05# tar -tf /mnt/cf/2007-06-21-09-19.backup | grep Drafts | grep cur | head -n1
A more complex way to get the pathname, for those of you who know sed, is
pipe the output of
tar's listing through grep and sed where I delete all lines containing the files in "cur".
It is unnecessarily complex in this particular
example, but might be handy in other cases:
bash-2.05# tar -tf
/mnt/cf/2007-06-21-09-19.backup | grep Drafts | grep cur | sed '|cur/*|d' home/root/tkcMail/Drafts/cur/
I still have trouble extracting subdirectory contents from a
tar file in a way that does not result in extra, unwanted subdirectories. So I will first extract the files to a temporary working directory created just for this purpose, and then move just what I need to the appropriate directory on my Zaurus itself.
Note that before I do that, I am change my working directory to that temporary directory, using the "cd" command.
If you do not have a suitable temporary directory, you can make one with the mkdir command:
bash-2.05# mkdir /mnt/cf/temporary-dir-name
In this example, I have already created a directory called "/mnt/cf/Drafts". I am changing my working directory to that special directory, and I am then asking tar to extract just the contents I need as follows, putting the output in the temporary directory on my cf card:
bash-2.05# cd /mnt/cf/Drafts-------snip--------
bash-2.05# tar -xvf /mnt/cf/2007-06-21-09-19.backup home/root/tkcMail/Drafts/cur/* &
The files I wanted were extracted to the directory on my CF card called /mnt/cf/Drafts/home/root/tkcMail/Drafts/cur.
If you have gotten lost trying to follow the above examples, the syntax for extracting the entire contents of a subdirectory is:
tar -xvf exact-path-to-backup-file exact-path-to-desired-directory/* &
Note that I have seen instructions, elsewhere on the web, to use the command
"tar xvf backupname subdirname", but BusyBox's
tar command on my
Sharp ROM, a minus sign is necessary. I also found that I have to use an asterisk (*), to get
tar to unpack the contents of a directory.
I then can copy the files in the Drafts directory on my CF card into place in internal memory:
bash-2.05# cp -p /mnt/cf/Drafts/home/root/tkcMail/Drafts/cur/* /home/root/tkcMail/Drafts/cur
Or I can move the files into place, in internal memory, as follows:
bash-2.05# mv /mnt/cf/Drafts/home/root/tkcMail/Drafts/cur/* /home/root/tkcMail/home/root/tkcMail/Drafts/cur
I was sorry my last backup was two weeks before this happened, so my most recent work was not retrievable, but at least the other drafts I had been working on are now available to me.