[Miscellaneous Android Development] alecxs:
[TUTORIAL] How to convert stock backup into TWRP backup

First of all you need to know, that userdata_yyyymmdd_hhmmss.backup files contain user data only. it is NOT a full nandroid backup like TWRP / CWM.

So we can just restore data partition from TWRP:

userdata_20160823_100259.backup -> data.ext4.win000 -> /data

The data partition contains the Internal Virtual SD Card. It is usually not included in TWRP backup. It is your decision to manually copy back to phone (recommended). But you can also restore Internal Virtual SD Card from TWRP:

/data/media/0 -> /storage/emulated/0

IMEI and WiFi MAC-Address:

/data/nvram (NOT recommended)

If there is a copy of NVRAM partition in folder /data/nvram, the script will delete it by default. However, there is a option to use IMEI and WiFi MAC-Address from backup (clone), instead from Phone.

Windows Users please click here

download UNetbootin -> https://unetbootin.github.io <- scroll this page down for tutorial

format USB flash drive FAT32

install any Linux Distro to USB flash drive

Reboot your PC from USB flash drive

to access the boot menu while booting your computer:

- press the appropriate key F11 or F12 during the initial startup screen

- select the USB boot option in the BIOS boot menu

- boot Default entry

congratulations, you have

sucessfully entered your

own working Linux system!

it's easy, isn't it? :)

Now, come back to xdaforums.com

- find Start Menu on upper left corner

- open the "Web Browser" from Favorites

- search for "bckp2win" in google

you can add your Keyboard Layout from: Settings - Keyboard

Note: performance of Firefox badly depends on USB flash drive speed

if it is too slow, try another one, or disable persistence:

- find syslinux.cfg file on USB flash drive

- open syslinux.cfg file with editor

- delete --- persistent from Try Xubuntu without installing entry

- save the changes, reboot from USB flash drive Try Xubuntu without installing entry

However, without persistence it is a read-only Live system and will lose all settings on reboot

Let's begin with preparations

- copy UPDATE-sdcard.Fix.Permissions-signed.zip to microSD card / or

- download UPDATE-sdcard.Fix.Permissions-signed.zip to target phone

- connect the source phone USB cable / or

- insert the microSD card into the PC's SD Card Reader

- copy all userdata_20160823_100259.backup files to any folder on local disk

- download all the zip files from this thread

- unpack zip files to same folder on local disk

run the shell script in Terminal

- do right-click somewhere in the backup folder, select "Open Terminal Here"

- type "sudo bash bckp2win.sh" in Terminal

- check disk space

example: when backup is 2 GB,

Avail must > 2,4 GB (120%)

when backup is 55 GB,

Avail must > 66 GB (120%)

- check file system type

Type must

not

vfat, fat32

all others allowed

(ntfs, ext4, fuseblk, ...)

this is very important! otherwise it will fail at the end and waste your time, and you won't know the reason. so please check carefully

- select file number to extract

- wait a long time, depends on disk speed and backup size (1~2 min / 1 GB)

Halftime break

- when message appears Press 'y' to unlock: [y/n] - Congratulations! The backup is sucessfully extracted

(if you need to edit/modify/delete files within backup this is the point for break)

- to continue with re-packing:

answer all questions with No

(or just press Enter for default):

Android sparse image (simg2img) support -> No

Flash-Friendly File System (F2FS) support -> No

unlock screenlock pattern -> No

clone old IMEI and Wifi Mac Address -> No

Restore /storage/emulated/0 -> No

use gzip compression -> No

Extract Internal Virtual SD Card to local disk -> Yes

(this will extract /data/media to TWRP folder instead, but exclude it from backup)

- wait for the script is finished

- wait for background processes

(it happens sometimes script finishes too early, if there is a data.ext4.win000 + data.ext4.win0000 file, just wait for the target size 1 GB each file)

- if checksums missing or failed, please manually run twrp_sign.sh again

(successful checksums look like this)

Finally we can restore the new backup

- copy back TWRP folder to phone

- boot into recovery mode

- create a failsafe backup (just in case...)

- move folder to the right location via MTP, or

- Advanced -> File Manager -> TWRP/BACKUPS/<serialno>/<backup folder>

- Options (blue icon on the right bottom) -> Move -> TWRP/BACKUPS/<phone name> -> Swipe to confirm

(in case converted backup is not visible in Restore list...)

- restore converted backup from TWRP

- install the flashable UPDATE-sdcard.Fix.Permissions-signed.zip

(just in case you have added files to data/media...)

- boot the phone

- move/copy all your pictures videos etc from TWRP folder back to phone