Menu

Twrp backup restore

2018-01-29
2019-03-25
  • Jonathan Anderson

    Twrp seems to add some rows. 
    $ java -debug -jar "/home/jonathan/Downloads/Android Backup Utilities/Android Backup Extractor/android-backup-extractor-20171005-bin/abe.jar" unpack backup.ab backup.tarInvlaid Magic: TWRPtwstreamheader¨G+TWRPtwfilename h?fs”/external_sd/TWRP/BACKUPS/88f12f77/2018-01-22--10-32-14_onyx-userdebug_7.1.2_NJH47F_4cb9ee3dc1/system.ext4.winTWRPtwdatablockDÝíº/addon.d/00407550000000000000000000000062132311571050011257xustar  rootroot50 RHT.security.selinux=u:object_r:system_file:s0Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid Magic TWRPtwstreamheader¨G+TWRPtwfilename h?fs”/external_sd/TWRP/BACKUPS/88f12f77/2018-01-22--10-32-14_onyx-userdebug_7.1.2_NJH47F_4cb9ee3dc1/system.ext4.winTWRPtwdatablockDÝíº/addon.d/00407550000000000000000000000062132311571050011257xustar  rootroot50 RHT.security.selinux=u:object_r:system_file:s0 at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:502) at org.nick.abe.Main.main(Main.java:128) ... 5 moreCaused by: java.lang.IllegalArgumentException: Invalid Magic TWRPtwstreamheader¨G+TWRPtwfilename h?fs”/external_sd/TWRP/BACKUPS/88f12f77/2018-01-22--10-32-14_onyx-userdebug_7.1.2_NJH47F_4cb9ee3dc1/system.ext4.winTWRPtwdatablockDÝíº/addon.d/00407550000000000000000000000062132311571050011257xustar  rootroot50 RHT.security.selinux=u:object_r:system_file:s0 at org.nick.abe.AndroidBackup.extractAsTar(AndroidBackup.java:332) ... 6 more

    Skipping them helped but I don't get all data from an extraction. Help would be really appreciated :-)

    Check your file:
    $ head backup.ab

    Twrp has added some things in the beginning. Skipping those with:
    $ dd if=backup.ab bs=512 skip=3 | head

    Got me to a semiworking extraction.

    $ dd if=backup.ab bs=512 skip=3 | tar -x

     
  • dragomerlin

    dragomerlin - 2018-01-30

    Since you have your device rooted, could you try using ClockWorkMod (cwm)? I don't trust TWRP very much. Also Titanium Backup is very good for rooted devices.

     

    Last edit: dragomerlin 2018-01-30
  • Jonathan Anderson

    No. I would have loved to try this, but the screen was broken and I managed to pull out a backup with TWRP. As I thought I had a backup, I proceeded to dissassemble the phone in a try to fix it and it is now in parts waiting for repair.

    Another project with this issue:
    https://github.com/julien-lang/twrp-adb-backup-extractor

     
  • dragomerlin

    dragomerlin - 2018-01-30

    Ok, I don't know what kind of backup you did, but I just tried today with twrp-3.2.1-0 and it just generated simple tar files, provided that you don't choose compression or something like that. The file list for my device is:

    boot.emmc.win
    boot.emmc.win.sha2
    cache.ext4.win
    cache.ext4.win.sha2
    cache.info
    data.ext4.win000
    data.ext4.win000.sha2
    data.ext4.win001
    data.ext4.win001.sha2
    data.info
    efs1.emmc.win
    efs1.emmc.win.sha2
    efs2.emmc.win
    misc.emmc.win
    misc.emmc.win.sha2
    radio.emmc.win
    radio.emmc.win.sha2
    recovery.emmc.win
    recovery.emmc.win.sha2
    recovery.log
    sns.ext4.win
    sns.ext4.win.sha2
    sns.info
    system.ext4.win000
    system.ext4.win000.sha2
    system.ext4.win001
    system.ext4.win001.sha2
    system.info
    

    It looks like your TWRP did a weird kind of .ab file. Never happened to me before.

     

    Last edit: dragomerlin 2018-01-30
  • alecxs

    alecxs - 2019-03-24

    screen was broken so the only option left was backup from adb:
    https://twrp.me/faq/openrecoveryscript.html

    adb backup --twrp compress data
    

    twrp produces his own backup.ab, which is just a normal data.ext4.win with a 1536 bytes header:

    00000000  54 57 52 50 00 00 00 00  74 77 73 74 72 65 61 6d  |TWRP....twstream|
    00000010  68 65 61 64 65 72 00 00  01 00 00 00 00 00 00 00  |header..........|
    00000020  03 00 00 00 00 00 00 00  3b cd 25 5d 00 00 00 00  |........;.%]....|
    00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00000200  54 57 52 50 00 00 00 00  74 77 66 69 6c 65 6e 61  |TWRP....twfilena|
    00000210  6d 65 00 00 00 00 00 00  b4 46 e4 f2 00 00 00 00  |me.......F......|
    00000220  01 00 00 00 00 00 00 00  4d cb 1c d4 2f 64 61 74  |........M.../dat|
    00000230  61 2f 6d 65 64 69 61 2f  30 2f 54 57 52 50 2f 42  |a/media/0/TWRP/B|
    00000240  41 43 4b 55 50 53 2f 43  55 42 4f 54 5f 4b 49 4e  |ACKUPS/CUBOT_KIN|
    00000250  47 5f 4b 4f 4e 47 2f 32  30 31 39 2d 30 33 2d 32  |G_KONG/2019-03-2|
    00000260  34 2d 2d 31 33 2d 34 31  2d 33 33 5f 43 55 42 4f  |4--13-41-33_CUBO|
    00000270  54 5f 4b 49 4e 47 5f 4b  4f 4e 47 5f 37 30 38 31  |T_KING_KONG_7081|
    00000280  43 5f 56 31 36 5f 32 30  31 38 30 35 31 37 2f 64  |C_V16_20180517/d|
    00000290  61 74 61 2e 65 78 74 34  2e 77 69 6e 00 00 00 00  |ata.ext4.win....|
    000002a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00000400  54 57 52 50 00 00 00 00  74 77 64 61 74 61 62 6c  |TWRP....twdatabl|
    00000410  6f 63 6b 00 00 00 00 00  44 dd ed ba 00 00 00 00  |ock.....D.......|
    00000420  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00000600  1f 8b 08 00 5e cf 97 5c  00 03 ec 5d 09 5c 54 d5  |....^..\...].\T.|
    
     
    • dragomerlin

      dragomerlin - 2019-03-25

      TWRP makes a raw backup of the ext4 filesystem, which has nothing to do with the real "adb backup" which is a tar filesystem. If you want to restore the TWRP backup you need to root the destination device, you can't use adb restore because Google's adb doesn't allow direct modification of the filesystem.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.