[LG V20 Guides, News, & Discussion] carhart2:
Backing up userdata with partitions.py

My comment is a question about using what's been built here for a related purpose:

I want to do a full backup of my LG V20 (Tmobile) device before rooting. I have invested a lot of time configuring my device, and I'd rather not redo that work. I don't really trust cloud backups, and am not content with Helium/adb backups for which at least half of my apps have opted out.

So I have been puzzling over this question: How do I take a full backup of the userdata partition on my V20 before I wipe it out?

Whether I use Titanium Backup, flash a custom bootloader like TWRP, or just execute TWRP once as a one-off, it seems all methods to get a full byte-by-byte copy of the /data partition involve having an unlocked bootloader. And unlocking the bootloader will erase my userdata partition. Which I can't do until after I have a satisfactory backup.

All my google searches landed me on one conclusion: Getting a full backup of EVERYTHING is impossible without first wiping out my data. I had just about thrown in the towel when I read about the lafsploit work. And I was intrigued.

I was able to downgrade to H91810p without impacting my data. I booted into FWUL and played around with the provided tools. I read the contents of the 'step1.sh' script and wrapped my mind around what it does.

I experimented with partitions.py, ultimately trying this:

(Grab the userdata partition and write it into a file located on a big hard drive)

./partitions.py --dump /mnt/extdrive/userdata.img userdata

...This ran for a while and produced a 54GB file.

So....Did I just get a full back of my data? !? What format is this file? Who or what can read it? Can I mount it with '-o loop'? No, I can't.

And most importantly: How can I restore it?

I borrowed an unused LG V20 from a friend to try restoring the file.

First I tried using it to flash with fastboot:

fastboot flash userdata /mnt/extdrive/userdata.img

...No luck. After it warned that this was an invalid sparse file format, the flash took a long time and eventually failed with an error. I don't recall the message, but it looked unrecoverable.

So then I took the borrowed V20, installed TWRP using the LAFsploit, booted into TWRP, unmounted /sdcard and /data, and tried adb:

adb push /mnt/extdrive/userdata.img /dev/block/sda20

...This ran to completion and looked promising. But mounting /dev/block/sda20 returned: "Unknown error 150"

So...Then I flashed the original LAF back onto the borrowed V20. I got back into download mode and tried restoring with partitions.py:

./partitions.py --restore /mnt/extdrive/userdata.img userdata

This ran for 15 or so minutes, and then errored out:

[ 0 % ] Traceback (most recent call last):

[...]

RuntimeError: Command failed with error code 0x80000019 (LAF_ERROR_<unknown>)

Any ideas what's going wrong here? Can the file created by partitions.py be restored by some other mechanism?

If I managed to get this to work, would it be helpful to more than just me? Or is this use case - Wanting a COMPLETE backup before rooting - too rare to be interesting?

I realize there are lots of threads online discussing backups, and the consensus is that you can't to do a backup of absolutely everything without root.

But I am extraordinarily stubborn! :)

I am commenting on this thread because my attempt at getting a good backup piggybacks on the lafsploit work that was discussed in this thread.

Please let me know your thoughts on this. Thank you!

Allan