New Magisk module enables TWRP to backup internal storage

In the everlasting iOS versus Android debate, the former has an advantage in case of backup. You can just hook up your iPhone or iPad with your Mac/PC, open iTunes and create a complete 1:1 backup of your phone. This is something Android still lacks of.

android_google_drive_backup
Google’s backup solution in Android is still lagging behind Apple

In last few years, Google vastly improved Android’s data backup and restore routine. Nevertheless, components like saved Wi-Fi passwords or individual app data still need root access to be backed up properly.

Power users often use custom recovery (like TWRP) to make the identical clone of their app data. However, you can’t directly restore the data on ROMs signed with different signing keys than the original one. Moreover, you can’t backup the internal storage.

twrp
The main menu of TWRP: Notice the ‘Backup’ and ‘Restore’ options

The internal storage (often mentioned as internal sdcard or sdcard0) is part of the /userdata partition of Android devices. It used to be a separate partition in the earlier days of Android, but Google decided to fuse it with /data (as /data/media) to avoid complexities.

As TWRP by default stores the backed up data in the internal storage, the path itself is not marked as a valid location for the backup job. I’m quoting from TWRP FAQ:

Creating a backup of the user data partition will NOT include /data/media (your internal storage)! That means if you save photos or data on the internal storage (e.g. some apps will save data there as well) those will be NOT included in a TWRP backup! There are many people thinking that this is the case but due to a decision taken by the dev team this is the current way of how it works.

To be absolutely clear when you do something like this:

* Creating a full backup in TWRP (including /data partition)
* Factory resetting your phone
* Restoring your previously taken full backup
* Result: all your saved data will be there but your data on the internal storage gets LOST!

There are unofficial workarounds to force TWRP to backup the internal storage, but the implementations are rather hacky and not future-proof.

XDA user ianmacd, who is the official TWRP maintainer of Samsung Galaxy S10 lineup, has stepped in and created a handy Magisk module to patch the TWRP image on the fly. Dubbed as TWRP Helper, users can make a true backup of their data using TWRP after patching the recovery with the module.

Once you have a successfully patched TWRP recovery image, you can reboot to TWRP and make immediate use of the augmented functionality.

Set your language to English and select the Backup module from the main menu and you should now see Data annotated with (incl. storage), where formerly the text (excl. storage) would have appeared.

Back-ups of Data will thus henceforth include Internal Storage (/data/media). Analogously, wiping Data will subsequently also wipe Internal Storage. This has two critical ramifications.

The source of module can be found here. The module itself is available on the Magisk repo and will be automatically updated every time the developer pushes some changes.

The module has been tested on Samsung S10 (G973F) and S10+ (G975F) devices running TWRP 3.3.1, where it performed as expected. Although the module has not been tested on any other model of device, it is likely to work on many devices with a standard A-only partition configuration.

Don’t try to use the patch on devices like the OnePlus 7 Pro yet, as it comes with A/B partitioning scheme. Hopefully the developer will soon add the support for such devices.

If you’re facing some bugs with the module, you can always revert back to unpatched mode. Meanwhile, creating a issue regarding the bugs in the GitHub repo of the module regarding the is highly recommended.

When you mark the module for removal in Magisk Manager, the module will inspect the recovery partition one final time during the next boot of the device to rooted Android. If a previously patched image of TWRP is found, it will be reverse-patched to return it to its former state.

Have you rooted your phone with Magisk? Comment below.

PiunikaWeb is a unique initiative that mainly focuses on investigative journalism. This means we do a lot of hard work to come up with news stories that are either ‘exclusive,’ ‘breaking,’ or ‘curated’ in nature. Perhaps that’s the reason our work has been picked by the likes of Forbes, Foxnews, Gizmodo, TechCrunch, Engadget, The Verge, Macrumors, and more. Do take a tour of our website to get a feel of our work. And if you like what we do, stay connected with us on Twitter (@PiunikaWeb) and other social media channels to receive timely updates on stories we publish.

Want to work for PiunikaWeb and enjoy best-in-industry compensation & benefits? You'll be glad to know we're hiring experienced candidates.

Tags : ,

Kingshuk De

I came from a mixed background of Statistics and Computer Science. My research domains included embedded computer systems, mobile computing and delay tolerant networks in post-disaster scenarios. Apart from tinkering with gadgets or building hackintosh, I like to hop on various subreddits and forums like MyDigitalLife and XDA.