Showing posts with label backup. Show all posts
Showing posts with label backup. Show all posts

Wednesday, December 31, 2014

... and how to restore it

As noted a couple of days ago, I broke my Nexus 5 and managed to get a backup via adb.

Finally, UPS managed - as usual with their second attempt and one call in between - to deliver the new Nexus 5 yesterday.
So, unbox, switch on, log into Wifi, etc etc... and have the system update to 4.4.3.

What?!?
Say Again!

"... and have the system update to 4.4.3."
No matter how often I repeat this, it's still weird that a brand new Nexus 5, ordered and shipped directly from Google, comes with 4.4.2 the end of 2014.

Anyway, update to 4.4.3, reboot, update to 4.4.4, reboot, update to 5.0....
Nope.
No 5.0. No Lollipop. As we know, rechecking every 5 seconds for an Android over-the-air update is as useful as hitting the elevator call button 10 times.

Well, so enable developer options with the 7x tap on the Build Number. Enable USB debugging.
Connect to PC, authorize, find the device with "adb devices". Voila.

Let's try the "adb restore". Enter the password on the mobile, this time without the help of the "adb shell input" workaround. The restore starts, and ends without any further message after about 2-3 seconds.

Not good.
Lets check the log with "adb logcat". There's something about mismatched header versions, so lets google this.
Well, as can be expected you cannot restore a 5.x backup to a 4.x device.
How silly of me to even consider it.

Recheck the over-the-air upgrade.
Nope, still not 5.0.

So screw it, download the factory image for 5.0.1.
Unlock bootloader, apply image, as described.
Reboot, log into Wifi, ...
Then the new Lollipop Setup Assistant kicks in and allows me to actually place my old phone to he back of the new one to NFC pair them, and transfer the basic settings (mainly account and Google settings) directly.

So I plug in the USB mouse again to the old, broken Nexus 5, and try to find the NFC settings (which are of course in the broken part of the display). Google around a bit to find there in the settings they are, and manage to half blindly enable NFC.
A couple of seconds later I have my account and (Google) launcher settings on the new Nexus 5.
Nice.
A lot of the app icons on the home screen are marked to show that the app itself is (still) missing behind the icon.

So I tried to restore the backup.
Again enable developer options (I just loaded a new system image, so everything I did an hour ago was of course gone) and USB debugging (and sideloading).

And now the "adb restore" really did work. Since there is no proper status on the device itself, I started a "adb shell logcat -s BackupManagerService" in another window to see some progress.

And about half an hour later I was done.
Most apps had their settings again, but not all.

Considering what last-resort hack this was, pretty good.
Considering how easy it is, to upgrade from one iPad to the next (via iTunes) this was pretty ugly.

By the way:
The Setup Assistant from Lollipop now supports a lot of options, even restoring data from a previous backup.
But I was not really inclined to test this right now.
If someone wants to sponsor yet another Nexus device for me, I'd be happy to test this for you.

Sunday, December 28, 2014

How to Backup a Broken Nexus 5 via USB

So, the other day I decided to drop my beloved Nexus 5 - display first - on a concrete (or stone, whatever) floor, right in the middle of Vienna's most busy shopping street. And got a result like this:

Not only was the glass broken, but the display itself was defect in large areas as well. Touch of course did not longer work.

I visited a repair shop just down the road, and guess what, they only have Samsung and Apple spares on stock, and I got the tip to use a cover next time. Yeah right, Thanks a lot.
So with the broken display and all, I decided to purchase a new one (via Play store), which is en-route to Vienna right now.

In the meantime I was trying to save whatever I can from the old device. My Nexus is unrooted without even a hint of Titanium Backup or the likes activated. Luckily I enabled the developer options as a first step after I got it.
So I connected it via USB to my PC and saved whatever as accessible this way.

I have the Android Developer Kit / SDK Tools installed on my PC, so I have adb at hand - the Android Debug Bridge, which is needed for the following steps.

Then I tried an "adb backup", which prompted for a confirmation on my device.
Of course, with no touch and the broken display I could not enter one.

So, the ultimate hack of 2014 to the rescue:

Step 1.
Connect a USB mouse via USB converted to the phone.
Yes, I really wrote that. A regular (PC) USB mouse. And you'll also see a regular mouse pointer on the display then. How cool is that.


Unlock the phone by drawing the swipe pattern with the mouse.

Then immediately (with the mouse again), go to settings and change the pattern to a PIN.

The PIN can be easily sent via USB from the PC, the pattern less so. Now we can disconnect the mouse again.

Step 2.
Connect the phone to the PC again.

Run "adb devices" just to be sure you are connected (all adb commands are of course from the windows command line or whatever your "host" operating system is).

If you are stuck with the lock screen, you need to swipe up with the following adb command[1]:
adb shell input swipe 500 1900 500 900

Then you should get the PIN prompt.

Unlock it with a sequence like this:
adb shell input text 1234 
adb shell input keyevent 66

The first line sends the PIN (1234 in this example), the second line sends the ENTER after it.  The event codes can be found in the Android Developer docs or here. The POWER, ENTER, BACK and HOME keys/events are quite useful :)

Step 3.
Start the backup with
adb backup  -apk -obb -shared -system -all

(or whatever options you require)
Then you'll get the full backup confirmation prompt, which needs to be answered again with the help of  adb shell input commands.
You can set a password with
adb shell input text password  [2].

However, it does not accept the keyevent 66 to confirm this dialog; this literally inserts a new line at the end of the password.
We have to tap on the "BACK UP MY DATA" button at the right bottom of the screen. Which leads us to

Step 4.
Luckily you can also emulate touch events via USB. Some research, some guessing, and trial and error showed, that this button is roughly in the area of coordinates 800,1750   (so in the right third and just above the button bar). The display is 1080x1920 in size, so that was easy to guess and test.
So we send a
adb shell input tap 800 1750

And the backup starts.
Magic.

Tomorrow I shall hopefully receive my new Nexus 5 (if the UPS guy for once delivers on the first attempt) and then I can report on how the migration to the new device works.

--

[1] The screen is 1080x1920; so the start position for our swipe is 500/1900 , i.e. quite in the middle, almost on the bottom, the end is 500/900, i.e. quite in the middle, quite in the middle, and almost perfect swipe to unlock.
[2] substitute your real desired password for password here, right after text.

Saturday, April 13, 2013

Two random yet timely thoughts on Android

1.  I finally gave up (to wait for JB ever to be released by HTC for the S3 variety of the One S) and had my "old" HTC One S (the one with the S4 chip) repaired.  Got the phone back 20 minutes before we went on a  a marvelous week of vacation with the family in Nice, France. So, finally, when we came back it was time to migrate from One S to One S.
Thus I - again - ran into the issue of Back / Migration of Android.
Not an easy task.

First, there is the Android 4+ trick of using the Android dev kit (ADK) on the PC, connecting the phone via USB and running
adb backup –apk –shared –all
That was the easy part, especially since as an Android developer I of course have ADK on my PC:
The  adb restore to the other phone did not work for me, because it always stopped with an exception after a while.
When trying to root my phone to get Titanium Backup to run, I must have selected one wrong option - it only takes one - and totally erased my phone.
Good thing I had the adb backup files.

So...breath deeply... root the "new" phone... because this is pristine anyway, login with google account, go to Google Playstore on the web and click through all the apps to re-send them to the phone.
Run adb restore for the data only, to get all text messages and other data back.
Worked quite fine, most of the apps found their settings again.
Took me altogether like 5 hours or so.

Then, take the S3 variante - the one I just got rid of - and set it up for my wife... Moving from a Gingerbread Samsung Galaxy S (the "old" I9000 one) is harder, because adb backup does not work there.
Anyway, I pulled most of the data through USB file system mode. Register her account on the new phone, restore some select folders from the PC (like media, and beyond pod, ...) ... 2 hours and it was done.

This is probable the only realm where apple is still ahead... Migrating a phone through an iTunes or iCloud backup is really easy. As easy as it can be.

Google / Android: This is where you need to learn from Apple. You really have to.



2. Facebook last week announced their Facebook Home for Android.
Good thing. Instead of building their own phone, they just "skin" Android and potentially all hardware. Seems to be 4+ only, which is OK as well.
Not sure, however, if their premise is right: What do they mean, that I want "people" on my phone, not "apps"?
It will be a success, because Facebook junkies might use it. I personally rather have my widgets on my home screen, and not 100% Facebook. I don't even have any of the social/facebook/google+... widgets active on my home screen, so this part of Facebook home is not for me.

The chat heads (talk about a fit yet bad name) seem to be interesting; non intrusive / disruptive chat layers on top of the apps might actually work, especially if the combine SMS/text and facebook chat (and the other messaging services in the future maybe).

I'm not talking about the privacy aspect here. Facebook does have a worse track record than Google, so not sure I want them to have total access to my phone and thus contacts, location, texts, ... But that's a different story

It is, however, a wonderful testimonial for the power of Android. A truly modular and open architecture.

Monday, September 24, 2012

Oh boy!

Last Friday, late  afternoon, just when we arrived at our b&b for our 2 days vacation in Styria, my beloved HTC One S went into a reboot loop. Meaning, it would power off, restart and right after the HTC logo reboot again, and again, and again, ... forever.
Didn't change when connected to power.
Didn't change when I let the battery run out (which was fairly fast and easy with this behaviour).
Nothing.
After about 2 hours I was not only really annoyed, but also quite allergic to the Quietly brilliant logo and sound.

So I finally managed to get into the bootloader or diagnostics menu (or whatever it is called). The one you get when you press volume-down while powering up. There I - after some playing around - decided to go for a factory reset.
This helped.

Bad thing is, I only had a 2 months old Backup I took with My Backup Pro. Not only that, I didn't actually have it, because it was on the memory of the phone I just wiped...
At this time, I really wished, the HTC One still had physical SD cards...

And this in the middle of nowhere. I only had an Edge connection from time to time.
Luckily the b&b had at least free Wifi, so I could re-install all my apps from Google Play.

From there it was easy: all contacts were synched with Google. Nothing to do there.
My emails, tasks, appointments are of course all "in the cloud" and/or on our corporate server(s), so once I logged into the respective app, it was done.
My photos/videos got periodically backed up to Dropbox with the automatic camera upload. Nothing lost there.
Most podcasts I had in Google Reader, and BeyondPod does sync with Google reader. Good.

The only real pain (apart from losing all my achievements in Temple Run) was to get the application settings back again. Still working on some of those.

Lesson learned: always do a backup and do it to an external medium or the cloud. Will set this up tomorrow.
Really.
I swear.