[Miscellaneous Android Development] alecxs:
Troubleshooting

WARNING: you need root permissions.

su binary not installed. you have to root your phone. SuperSU just manages app permissions. if you see a $ in terminal that means you are not root. type "su" and you will see a # in terminal. if you sure having root but warning persist, install busybox.

sh: unzip: not found

no busybox installed. open BusyBox app, grant su access, install busybox to /system/xbin or /su/xbin

unzip: can't open bckp2arm[.zip]

wrong folder. use cd command to navigate to download location, for example "cd /sdcard/Download".

sh: cd: No such file or directory

typo mismatch. unix filesystems are case sensitive. (for bckp2arm.ini have disabled that)

WARNING: file "bckp2arm.ini": not found:

/sdcard/userdata_20160823_100259.backup

Android 4.3+ higher: for full access to sdcard disable the mount namespace separation (do NOT change /system/etc/permissions/platform.xml). Simply uncheck SuperSU -> Settings -> "Mount namespace separation". If still no write permission, there is a app for changing platform.xml NextApp SDFix

WARNING: SELinux has been detected

Android 4.3+ higher: for full access to data partition, try to disable SELinux Enforcing with SELinuxModeChanger.apk (current state SELinux is experimental)

WARNING: Samsung KNOX has been detected

Android 4.3+ higher: try to disable KNOX by typing "pm disable com.sec.knox.seandroid" in terminal emulator. When uninstalling KNOX, you are asked if you want to backup your KNOX data. (current state SELinux is experimental)

WARNING: install GNU tar / p7zip for android.

download the zip files. just place it anywhere on sdcard. if you don't have ARM CPU, or if automatic unpack fails, download binary for CPU architecture and install to /system/lib /system/xbin (see SOURCES file) and set permissions 755 executable (delete any symlink with "unlink tar" before copy, otherwise you will destroy busybox). but its not required for newer backups - to ignore this checks, set params GNUTAR=0 P7ZIP=0 in bckp2arm.ini

WARNING: No microSD Card found.

removable flash storage device is not mounted. check your microSD Card / USB-OTG Stick on any computer. make sure you have a formatted 1st partition. don't remove unless script is finished.

WARNING: sdcard fat32 filesize limitation

backup files larger then 4 GB cannot unpacked to fat32 file system. the script will search for other partitions on sdcard and try to mount it. ntfs support depends on phone. reformat sdcard with linux extended file system, or create a new partition. same for usb-otg sticks. How to make Second Partition on SD-Card

WARNING: microSD Card sdext2-partition detected!

you have Link2SD or similar installed. set PROTECT_SDEXT=1 to use partition for temporary unpack or PROTECT_SDEXT=2 to preserve. if protected, the script will search for other ext2 partitions. if Link2SD /data/sdext2 partition is included in backup, set PROTECT_SDEXT=0 to restore.

WARNING: Phone is not in Airplane Mode / Charging Mode

to avoid disruptions caused by incoming calls or screen auto-lock timeout, always connect your charger and switch phone to offline mode. set USB_MODE=2 to enable USB On-the-Go (OTG) Mode and WiFi. setting USB_MODE=0 for unplugged mode is not recommended, this may throttle down CPU heavy as soon as display turns off. if flight mode is not detected, settings binary is missing. in this case install sqlite3 binary to /system/xbin or /su/xbin and set permissions 755 executable (see also page 3)

Phone storage full, the process has been stopped. Please free space and try again.

this happens during unmount data partition. anyway, terminal emulator still running fine. Simply ignore all Android Error messages and do nothing! just wait for the script is finished and phone is automatically rebooted.

ERROR: No space left on device

check space on sdcard / usb stick. for mergeing multipart backups min > 50% free space required. this means for a 16 GB phone you need a 64 GB microSD Card with two 32 GB (vfat) and 32 GB (ext4) partitions. another reason is running out of space on /data partition. this happens sometimes during restoring user data. do a factory reset before. if this not help, set PROTECT_SDINT=0 for delete internal storage /storage/emulated/0. if you run the script from computer with adb shell, set ADB_MODE=1 to free up additional lost disc space. for advanced restore / testing purposes it is possible (but not recommended) to set PROTECT_SDINT=1 to skip unpacking pictures etc. from internal storage backup (emulated sdcard). beware that each run will create a new backup file (dummy file) which is consuming space. delete these files to free up sdcard / usb-stick. for large backups > 4 GB free up sdext2 partition before each run.

ERROR: FAILED to restore user data

the backup file is unsupported format. sparsed ext4 images not supported yet, but you can convert into cwm format (see other thread). unfortunately, your /data partition is now deleted. reboot into recovery and make a factory reset and wipe cache partition. a new backup file exist (ext4 image). this backup file is restoreable from script only. if there is no backup file, there is a backup of your current data on sdext2 partition. but usually don't care about because you should have done factory reset before. just delete it ;)

Bugs & Known Issues

SELinux: GNU tar for android: security context not restored

Android 4.3+ higher: unfortunately GNU tar does not extract security context from tar archives (probably compiling issue). Unless you find a binary that supports tar --selinux, at the moment for SELinux only ext4 images are supported (but does not concern newer ext4 backups).

tar: Cannot change ownership to uid 0, gid 0: Bad file descriptor

probably bug of gnu tar? after successful unpacking ERROR: No space left on device occurs. set param GNUTAR=0 to disable gnu tar (instead busybox tar applet must symlinked, check it by typing "tar")

PROTECT_IMEI / preserve Phones IMEI and WiFi MAC-Address not working

If there is a copy of NVRAM partition in folder /data/nvram, the script will delete it on restoring by default. However, some phones don't have /data/nvram folder, therefore it will not be deleted. as a result the Phones IMEI and WiFi MAC-Address may used from backup (cloned), instead from Phone. To fix this, you have to delete some folder (or files) by your own. if you know how to fix it, leave a request which folder (or files) should be deleted from script