[Nexus 4 Q&A, Help & Troubleshooting] deoren:
I've since unlocked my phone, restored quite a bit of content, taken two Nandroid backups (before and after rooting the phone) and loaded all currently available versions of stock Android for the Nexus 4. What follows is some of my notes that I took while going through the process.

---

After unlocking my phone I restored contents from the zip file and a surprising amount of content was restored, but unfortunately not stuff like bookmarks and other personal settings. As I read before and after unlocking my phone a lot of that content is kept in /data where only root can get to it. Thankfully not all app developers follow that recommendation and I was able to retrieve some of my content.

However after I unlocked the bootloader and rooted the phone I was able to make a backup by running:

adb backup -apk -shared -all -f nexus4-backup-010414.ab

I'm not sure if it was just unlocking the bootloader that allowed it to work or that + rooting the phone or maybe something else entirely. Whatever the case that command completed successfully. I'm going to run several more backups with differing options and then will flash the phone back to stock and try restoring from that.

Just before that I'll try making a backup via TWRP (haven't really looked into the details yet) and also follow the

codemink.com/backup-or-restore-android-through-adb/

guide to try and make a backup of the entire phone (OS, Recovery, etc).

I'm hoping I don't have to spend all of my time restoring the phone from scratch if this doesn't work, but it's worth trying this to find a reliable solution.

---

I picked another tool from the tool chest and tried using the Nexus Root Toolkit (NRT) v1.8.0 since others have recommended it. I know it's not good to rely on toolkits, but I wanted to see what it was capable of. It rebooted the phone into bootloader mode and then booted a custom recovery (TWRP) so it could run a Nandroid backup. It did and ended up with a 2.30 GB backup located at /sdcard/TWRP/BACKUPS/SerialNumberOfYourPhone/. From what I can tell the NRT automates what you can do manually, only when it finished the process and attempted to copy the backup to the PC it only grabbed about 40 MB worth and reported a successful backup.

Since I had been watching the process from the phone I saw that it reported the size of the data it was backing up as 2750 MB, so I knew that the NRT was wrong. It asked if I wanted to nuke the backup since it copied it over, and I told it No since I knew it was wrong.

* If I haven't mentioned it yet, I used Windows 7x64 for all steps.

---

I followed the directions on the

www .android.gs/root-google-nexus-4-on-android-4-4-kitkat-krt16o-rom-using-twrp/

page and didn't have any problems. Well, the one problem I did have was not freaking out when my Nexus wasn't seen by either

adb devices

or

fastboot devices

.

I frequently made the mistake when experimenting on my own by using one or the other when it wasn't appropriate. I ended up learning that fastboot is used when interacting with the bootloader and adb is used when the phone is booted into the full Android OS or in Recovery mode.

After I had TWRP installed, the Android 4.4.2 installation rooted (again using the

www .android.gs/root-google-nexus-4-on-android-4-4-kitkat-krt16o-rom-using-twrp/

page and my phone setup the way I wanted it, I took a final Nandroid backup using TWRP and then booted the phone back into the full OS.

I proceeded to copy the /sdcard/TWRP backup files to the PC as a precaution. I ended up using the

developers.google.com/android/nexus/images#occam

official factory images for the Nexus 4 to flash Android 4.2.2 all the way up to Android 4.4.2 "just to do it". Restoring my TWRP backup first required me to re-flash TWRP and then copy the TWRP backup folder back to /sdcard/TWRP. I booted back into Recovery mode via adb reboot recovery and used the menu system to drill down to the backup I was interested in and restore it. I then rebooted when prompted and my phone was restored to where I last made a Nandroid backup.

I took extensive pictures using a second phone and kept all output so I could have something to refer to if (uhm, when) I try this again in the future.

What I learned at the end is that I could have flashed just the OS by modifying the flash-all.bat file to remove the -w switch from the final fastboot command in the file. Here is what it looks like by default for the file included in the Android 4.2.2 factory image tarball:

fastboot -w update image-occam-jdq39.zip

and after removing the switch:

fastboot update image-occam-jdq39.zip

Using that approach I would likely be able to safely keep the /sdcard/TWRP files on the phone during the flashing of stock roms. I hope this helps someone. Unfortunately I never did find a way to use adb to make a successful backup prior to unlocking the bootloader, so if I had it to do all over again I would have unlocked the bootloader when I first received it. Lesson learned!