Since an issue with the keyboard freezing for Android disk encryption was fixed in the Omnirom code base, I was able to upgrade my system again. Unfortunately, the system didn’t boot anymore without a factory reset. Therefore, I finally found out to manually restore individual apps from a system backup performed with TWRP.

The backup option of TWRP produces different files for the different partitions of your device. These files are (for backups without compression) simple tar archives of the data on your phone. In case of large volumes, the archives might be split into multi-part tar archives. A listing of the backup directory might look like this:

The app data is stored inside the data partition. So the first step is to extract this partition:

tar -xvf data.ext4.win000

This will result in a folder called data which will eventually contain the application data in the subfolder data (yes, same name). In order to push data from individual application to the phone we first need to restart adb on the phone with root permissions:

adb root

Afterwards, individual application data folders can be pushed to the telephone, e.g.:

adb push data/data/ /data/data/

Now the harder part begins. Android uses a single Unix user per application. First, the pushed files need to become owned bu the user of the application.

For this purpose, first the user id of the application needs to be found out. For this purpose the application needs to be installed already. On the phone, e.g. through adb shell do:

dumpsys package | grep userId

This will print out the user id of the app, with which the files can be changed:

chown -R $id:$id /data/data/

This is still not sufficient for the app to function properly again. If you try to launch the app now, chances are high that it complains about SQLite databases not being readable. This seems to be caused by SELinux, which is used by Android. The SELinux attributes of the files need to be restore, as described here:

restorecon -Rv /data/data/

Finally, the app should be restored.